Skip to main content
2 of 2
added 1067 characters in body
Les Lim
  • 2.4k
  • 13
  • 17

For starters, you're probably using the wrong array key for the field value that you're saving; 'name' should be 'value' there.

$node->field_par_contact_name['und'][0]['value'];

Second, you're actually using Taxonomy Term Reference fields for your "first name" and "surname" fields. One important point about Reference fields is that you can't always assume that the referenced entities have been fully loaded and are available in your object. By default, when the node object is loaded, that field only looks like this:

$node->field_par_contact_first_name (Array)
  'und' (Array)
    0 (Array)
      'tid' => 284

Only the 'tid' key is definitely there. 'name' is a property of the referenced term, and isn't usually automatically available. (Subsequent code may actually load the referenced term and make it available within the $node object, but that's just happenstance if so.)

You would have a much easier time of it if your "First Name" and "Surname" fields were text fields instead of references. Then, those values would belong directly to the node itself, rather than to a separate taxonomy term being referenced.

If you're stuck using taxonomy term references, though, then you should make a point in your code to load the referenced term, then get the values you need from the $term->name property itself.

Les Lim
  • 2.4k
  • 13
  • 17