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.
Can't get the function to work.
computed_field_field_myfield_compute ($node, $field, $node_field) {
$node_field[0]['value'] = "test";
}
This function works, but the node object is not available.
computed_field_field_myfield_display($field, $element) {
$display = "test";
return $display;
}
not storing data in database.
display function stops working when compute function is added.
Comments
Comment #1
driki_ CreditAttribution: driki_ commentedsame here
Comment #2
timhsieh CreditAttribution: timhsieh commentedI think that computed_field_field_myfield_compute should pass the $node_field parameter by reference rather than by value, otherwise you are making changes to a copy rather than the real thing. In other words, your declaration should look like this:
function computed_field_field_myfield_compute($node, $field, &$node_field){YOUR_STUFF_HERE}
(that is, with an ampersand in front of $node_field)Comment #3
mmjvb CreditAttribution: mmjvb as a volunteer commented