Closed (fixed)
Project:
Computed Field
Version:
5.x-1.2
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
25 Jan 2008 at 16:48 UTC
Updated:
20 Jan 2012 at 11:55 UTC
Jump to comment: Most recent
I've created a computed field and it all works fine, but there is one thing that disconcerted me for a while: the field does not appear at all when you are in edit mode! So although I can see the result of the field when I have actually created the node, I can't see it while I am in the process of creating although I marked it to 'display' - which I would quite like to do. Is there any way around this?
Comments
Comment #1
Justin Freeman commentedYes it is possible. See this tutorial HowTo: Theme a CCK input form
Comment #2
jibort commentedI found a workarround that worked for me.
1- Create a custom module o use and existing custom module
2- Implement "module_form_alter"
3- Write a code similar to
$value = $form['field_name_of_calculated_field'][0]['value']['#default_value'];
$form['testing'] = array('#value' => $value);
The last line of code creates a new element in the form of the type 'markup' (default type). I hope this help.
jordi
Comment #3
sansui commentedRather old thread, but I am looking for a similar solution. I have an age computed field that I need a label/markup for in my edit form to allow for cck private field options.
I am able to display the value on my form with my age value and privacy option, but it is falling outside of the CCK fieldgroup/fieldset that it should be in - 'group_profile_personal'.
Comment #4
clintthayer commentedFor some reason I'm still having issues with displaying a CCK computed field on the edit form. Don't need to edit the field, just display. If folks have example code to point me in the right direction - that would be helpful.
Comment #5
Anonymous (not verified) commentedI found a way to solve this problem //to display a field in edit mode :
Comment #6
clintthayer commentedThanks franck0015. I went a different direction by adding an additional CCK field and dumping the result of the computed field in. I'll keep this solution in mind if I need something more.
c
Comment #7
El Bandito commented@clintthayer
Any chance you could share your implementation method ?
Thanks
El B
Comment #8
agileadamHere's another method of showing the value of the computed field in the form. This illustrates how to add a markup field to the form that will show the user the current value or some placeholder text if they're creating a new node.
Note that this field will be displayed as HTML, so it's just to show the user the current value. It will not be editable.
This would go in a hook_form_alter().
Comment #9
deviato commentedHere's my method for showing a computed field in a cck multigroup:
Comment #10
akolahi commentedRegarding #6 & #7, you can use rules to assign the value of the computed field to a dummy text field. Furthermore you can make the field non-editable using conditional fields. This in effect will show the value of the computed field on the node/edit form.
Note that this will only work after the initial save and wont update on the fly (as should probably be the behavior).
Also, the form alter method is probably a better solution in that you don't need an extra field - however this solution is super easy to implement without a custom module.
Comment #11
akolahi commentedThis module will also do the trick. Just select 'read only' and it will show the view version of the field: https://drupal.org/project/field_extrawidgets