Skip to main content
edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
edited tags
Link
Kevin
  • 28k
  • 12
  • 95
  • 196
Source Link

PDOException when setting field value in node presave

I have a hook_node_presave implementation to set the value of a node field based on one of the user-entered values.

The code for it looks like this:

function er_pr_node_presave($node) {
  .....
  foreach($nameResult as $row) {
    $node->field_co_pi[LANGUAGE_NONE][$i]['value'] = intval($row->entity_id);
  }

  dpm($node);
}

With the dpm function I can see the values in the node, and the correct value is set to the field_co_pi field. However, the placeholder field doesn't get set when the insert query for that custom field is ran, resulting in a PDOException:

enter image description here