0

I have a custom module which defines a custom entity. On a content type, I have an 'Entity reference' field that let's me select a custom entity. The value is saved in the database (I looked directly to the database) but is missing when the node is viewed.

if I dump the $node in hook_node_update($node) I can see the referenced value is there. But on hook_node_view($nodes, $types) the value is gone.

The funny part is that in a view, if I create a relation based on this field, I can see the entity's fields, but not the entity reference field value :))

Other types of entities are displayed correctly though, the problem is only with my custom entity

Any help would be very appreciated :) Thanks

  • did you look at display setting page? – Mohammad Ali Akbari Apr 27 '12 at 17:15
  • yeah, I tried all the options available with no luck. – Marius Ilie Apr 27 '12 at 17:19
  • if you are using Entity reference module, which formatter you set in display setting? title only or rendered entry – Mohammad Ali Akbari Apr 27 '12 at 17:28
  • I tried all of them: label, entity ID and rendered entity. Nothing worked :( – Marius Ilie Apr 30 '12 at 8:46
2

I just Googled the same issue and was led to this page.

You need to implement an access callback in hook_entity_info(), else the entity reference field won't load the entity.

1

Still haven't found an answer so I decided to try the model module. Looks ok now :)

LATER EDIT: eck module seems the best way to work with entities

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.