I have a node type with a node reference field. Widget: autocomplete, formatter: hidden.

If I edit a node with the field correctly filled in I get an error page with the following errors:

Notice: Undefined index: node in node_reference_field_formatter_view() (line 428 of /path/references/node_reference/node_reference.module).

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7663 of /path/includes/common.inc).

If I save, I can view the node without errors.

The problem seems to be that on row 428, $item['node'] is not set:

$node = $item['node'];

And the reason for this seems to be that node_reference_field_formatter_prepare_view() doesn't run when previewing nodes – only when viewing them. Changing row 428 like below fixes the problem:

$node = isset($item['node']) ? $item['node'] : node_load($item['nid']);

Drupal 7.22, References 7.x-2.1

Comments

Alex Andrascu’s picture

Assigned: Unassigned » Alex Andrascu
Status: Active » Needs review
Alex Andrascu’s picture

Thanks for this. I'll give it a look.

Alex Andrascu’s picture

Status: Needs review » Closed (duplicate)