Closed (fixed)
Project:
Computed Field
Version:
5.x-1.1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
16 Apr 2007 at 08:12 UTC
Updated:
2 Oct 2020 at 20:25 UTC
Jump to comment: Most recent
Comments
Comment #1
yched commentedI think computed fields, by nature, can't be edited.
Maybe what you want is a regular number field, initialized using a 'default value' in the field's settings page ?
Comment #2
appel commentedWow, you're fast! Thanks for your reply! Do you think it's possible to select the last order number from the database and increment it by 1 in the 'default value' of a regular number field? I currently have this query in my computed field:
SELECT `nid`, `field_projectnumber_value` FROM `content_type_content_project` WHERE `field_projectnumber_value` != '' ORDER BY `field_projectnumber_value` DESC LIMIT 1;Comment #3
yched commentedYou can define the default value using PHP code, so inside that code you can do whatever you see fit.
Be aware that 'default values' for fields only pre-fill the node _creation_ form with the defined value. Once the node is created, the default value does not come into play anymore, and the field can be edited just like any other one (unless you use write some code with hook_form_alter to hide it in forms)
Comment #4
appel commentedThanks yched, I'll give it a try right away!
Comment #5
appel commentedOoof, that's kinda hard. At this point it doesn't seem to return any data from the $node object:
What am I doing wrong?
Comment #6
appel commentedNevermind, I got it working. Thanks!
Comment #7
colanComment #8
appel commentedWell if this isn't a blast from the past... :)