Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Does anyone know how to add two fields together?
I have tried looking through documentation but everything I used just comes back with 'undefined variable'.
I basically just want to add:
field 1 (which is a numerical value)
to
field 2 (which is a numerical value)
and display that in my computed field.
Comments
Comment #1
Rix-1 CreditAttribution: Rix-1 commentedOk it was my display output that was causing problems....
if it helps anyone else:
$display_output = $entity_field_item['value'];
Comment #2
Rix-1 CreditAttribution: Rix-1 commentedOk not that simple after all.
I need to add:
field 1 (which is a numerical value field on the node)
to
field 2 (which is a numerical value field from a taxonomy term custom field - the term is attached to the node)
Any ideas?
Comment #3
zkent CreditAttribution: zkent commented$values['payment_amount'][0] = $values['quantity'][0] * $values['cost'][0];
where 'payment_amount' is a textfield on page 2 of the multi-page webform
'payment_amount' is also where the macro code (above) lives
'quantity' is a number field on page 1
'cost' is a hidden field on page 1