Hi guys, like I said I need help with a PHP problem in a computed field. I'm a novice in PHP, but I do understand Drupal.
I've got 3 fields in a multifield. Two of them are numeric fields, the third one being computed.
Here is my code of my computed field:
$node_field[0]['value'] = $node->field_interim_weight[0]['value'] * $node->field_interim_score[0]['value'] / 5;
$node_field[1]['value'] = $node->field_interim_weight[1]['value'] * $node->field_interim_score[1]['value'] / 5;
$node_field[2]['value'] = $node->field_interim_weight[2]['value'] * $node->field_interim_score[2]['value'] / 5;
Everything works fine, but as you can make out, if ever I should add an extra multi-field, then my 4th field won't have a value.
Is there a variable I can use instead of inserting my delta values? Cause when I only have 1 value to insert, the rest shows zero.
I just want to know if I can make this process easier using PHP variables.
Any urgent help would be appreciated!
Thanx
Comments
Untested, but I think this
Untested, but I think this should work:
[edit: fixed php typo in the isset-statement]