Posted by sticky2010 on April 4, 2011 at 2:59am
Hi Guys,
I have recently joined NZ Drupal Group. I am a Junior Developer and am bit stuck on something. I am hoping somebody can help me out here.
I have a field called:
field_a | Type: text
field_b | Type:computed
so in my computed field I would like to do:
if ($node->field_a[0]['value']){
$var1="some text";
$var2="some more text";
$node_field[0]['value']="$var1.$node->field_a[0]['value'].$var2";
This doesn't display anything. I tried creating temporary arrays as well to achive the same thing but that doesn't work either. I am just wondering if this is the correct way to go about doing this or is there any other better method.
Please do advise and thank you for your time. Cheers.
Comments
You need to store the value
You need to store the value into the computed field. Have you implemented your own module or are you writing PHP into the default value in field definition for field_b?
If the former, make sure you are passing node_field by reference in the _compute function (e.g. &$node_field).
If the latter, your code needs to return an array.
Thank you
Thanks Jonathan.
Got it done. Cheers for your pointer.