Closed (duplicate)
Project:
References
Version:
7.x-2.1
Component:
Code: node_reference
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
10 Jun 2013 at 10:23 UTC
Updated:
12 Jun 2013 at 16:54 UTC
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
Comment #1
alex andrascu commentedComment #2
alex andrascu commentedThanks for this. I'll give it a look.
Comment #3
alex andrascu commentedLooks like this is a duplicate of #2010572: Undefined index: nid in node_reference_field_formatter_view() (line 481 of [..]/sites/all/modules/_basic/references/node_referen
I'll close this one and we'll keep it there.