I have tested the Entity Reference Autocomplete module by defining a form field of type entityreference
(via hook_form
) on the user
entity - and it works as advertised.
When I try it on my own entity an AJAX error is thrown.
My form element definition:
$form['name'] = array(
'#title' => t('Ground'),
'#type' => 'entityreference',
'#era_entity_type' => 'ground',
'#size' => 32,
);
I can't imagine the problem is my entity's base table. So, the only thing I can think of, which may be the source of the error, is my hook_entity_info
definition:
/**
* Implements hook_entity_info().
*/
function scorebook_entity_info() {
$return = array(
'ground' => array(
'label' => t('Ground'),
'controller class' => 'EntityAPIController',
'base table' => 'scorebook_ground',
'entity keys' => array('id' => 'grid'),
),
);
return $return;
}
It contains the minimum keys. Do I need to add some other keys to my definition? If anyone knows of a working example of this module working with a custom entity that may help too. Thanks.
UPDATE:
Here is the correct hook_entity_info
definition for anyone who doesn't want to read everything below. You need to define an access callback function, also, to return either TRUE/FALSE accordingly.
'ground' => array(
'label' => t('Ground'),
'controller class' => 'EntityAPIController',
'base table' => 'scorebook_ground',
'entity keys' => array(
'id' => 'grid',
'label' => 'name',
),
'access callback' => 'scorebook_access',
),