1 entityreference.module entityreference_autocomplete_callback($type, $field_name, $entity_type, $bundle_name, $entity_id = '', $string = '')

Menu callback: autocomplete the label of an entity.

Parameters

$type: The widget type (i.e. 'single' or 'tags').

$field_name: The name of the entity-reference field.

$entity_type: The entity type.

$bundle_name: The bundle name.

$entity_id: Optional; The entity ID the entity-reference field is attached to. Defaults to ''.

$string: The label of the entity to query by.

File

core/modules/entityreference/entityreference.module, line 1005
Entityreference primary module file.

Code

function entityreference_autocomplete_callback($type, $field_name, $entity_type, $bundle_name, $entity_id = '', $string = '') {
  // If the request has a '/' in the search text, then the menu system will have
  // split it into multiple arguments and $string will only be a partial.
  // Make sure to recover the intended $string.
  $args = func_get_args();
  // Shift off the $type, $field_name, $entity_type,
  // $bundle_name, and $entity_id args.
  array_shift($args);
  array_shift($args);
  array_shift($args);
  array_shift($args);
  array_shift($args);
  $string = implode('/', $args);

  $field = field_info_field($field_name);
  $instance = field_info_instance($entity_type, $field_name, $bundle_name);

  return entityreference_autocomplete_callback_get_matches($type, $field, $instance, $entity_type, $entity_id, $string);
}