Making Computed Field work with Flexifield
Last updated on
30 April 2025
Many people have stated that Computed Field will not work with Flexifield.
This example shows how to make it work and get a sum of multiple values from a Flexifield's sub-field.
Assuming 'field_my_flexi' is your Flexifield name, and that you have it set to allow multiple entries; and that you have a sub-field called 'field_flexi_price', and you want to get the sum of all prices for that Flexifield...
Computed Code:
$value1 = $node->field_my_flexi[0]['value']['field_flexi_price'][0]['value'];
$value2 = $node->field_my_flexi[1]['value']['field_flexi_price'][0]['value'];
$value3 = $node->field_my_flexi[2]['value']['field_flexi_price'][0]['value'];
$value4 = $node->field_my_flexi[3]['value']['field_flexi_price'][0]['value'];
$node_field[0]['value'] = $value1 + $value2 + $value3 + $value4;
Display Format:
$display = $node_field_item['value'];
Data Type: varchar
Date Length: 5
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion