I've attached a new entityreference field to users that referenced my custom entity type, say it's called my_entity
. When I dpm()
the user or view the tokens, I can see my custom entity properties (id, name, etc) but when I view the user I do not see the field label or the entity label.
I threw a dpm($items)
into hook_field_formatter_view()
inside entityreference.module
and
discovered that there are 0 items available to be displayed, but they are available in many other places! (as described above)
In hook_entity_info()
:
<?php
return array('my_entity' => array(
'label' => t('My Entity'),
'controller class' => 'MyEntityController',
'base table' => 'my_entity',
'uri callback' => 'my_entity_uri',
'load hook' => 'my_entity_load',
'fieldable' => FALSE,
'label callback' => 'my_entity_label',
'entity keys' => array(
'id' => 'id',
'label' => 'name',
),
);
?>
I tried just setting the entity keys['label']
to the schema field, which is supposed to be adequate to set the label, but I also tried 'label callback'
and even setting up the bundle info, which is not necessary for my entity.
I've also tried adding the property into hook_entity_property_info()
in the hope that it would be "made aware" to other modules, but no luck:
<?php
return array('my_entity' => array(
'properties' => array(
'name' => array(
'label' => 'Name',
'type' => 'text',
'schema field' => 'name',
),
),
);
?>
Any ideas?
hook_field_prepare_view()
which could help me out here.