I have installed this module today and whenever I try to save a content type which contains an entityreference I receive the following error.
Does anyone know how I can solve this?

EntityMalformedException: Permission to create a node was requested but no node type was given. in entity_metadata_no_hook_node_access() (line 665 of /sites/all/modules/entity/modules/callbacks.inc).

Comments

Anonymous’s picture

I think I already found the problem.

My entity reference field doesn't use the Simple mode, but the Views mode. It does work when Simple mode is selected.

Is there a workaround to make this work?

devtherock’s picture

I am too getting this error, its not only while creating content but this error also comes up when one try to edit fields. Anyone solved this issue, please share here.

highkb’s picture

I found the patch #319 to solve the problem on my page
https://drupal.org/node/1780646?page=1
Hope this helps.

devtherock’s picture

Thanks for the URL, checked #315 and made changes in "references_dialog.dialog_widgets.inc" in line number 225 because this line was fetching error, $bundle as string was passed in entity_access instead of object in. Below is the quick snippet of my code.

..
// run node_access('create')
$node = entity_create($entity_type, array('type' => $bundle));
  if (entity_access('create', $entity_type, $entity_type == 'node' ? $node : NULL) && ..
..

Now node edit/create and field edit working without any error.

JvE’s picture

Status: Active » Closed (duplicate)

Duplicate of #1780626: Entity Reference incorrectly calls entity_access() which is already solved.

Update to the latest dev version or wait for a new stable release.

Do not follow highkb's advice, that will introduce silent access check failures.