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

Rix-1’s picture

Ok it was my display output that was causing problems....

if it helps anyone else:
$display_output = $entity_field_item['value'];

Rix-1’s picture

Ok 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?

zkent’s picture

$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