I am creating an entity for my D7 Module and trying to include a user_reference auto-complete field in it. The autocomplete-field shows up correctly with the add-more option since I have set cardinality to unlimited.
However, nothing shows up in auto-complete suggestions and it doesn't accept any of the user-instances.
Even more annoying is that when I go and check the field settings in Home » Administration » Structure » Content types » » Manage fields and click on Save without making any changes, the suggestions start appearing correctly as they should.
I have written down the following settings for the field and the instance.
field :
'vocabulary_authors' => array(
'field_name' => 'vocabulary_authors',
'type' => 'user_reference',
'settings' => array(
'referenceable_roles' => array('2','3'), // for authenticated user + administrator
'referenceable_status' => array('1'), // for active
),
'default_widget' => 'user_reference_autocomplete',
'default_formatter' => 'user_reference_default',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
),
instance :
'vocabulary_authors' => array(
'field_name' => 'vocabulary_authors',
'label' => $t(' Authors'),
'bundle' => 'vocabulary',
'entity_type' => 'node',
'description' => '',
'required' => FALSE,
'widget' => array(
'type' => 'user_reference_autocomplete',
'settings' => array(
'autocomplete_match' => 'starts_with',
),
),
Please help me out here. I think I am I missing out on some required settings.