function entityreference_autocomplete_callback in Entity reference 7
Same name and namespace in other branches
- 8 entityreference.module \entityreference_autocomplete_callback()
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.
1 string reference to 'entityreference_autocomplete_callback'
- entityreference_menu in ./
entityreference.module - Implements hook_menu().
File
- ./
entityreference.module, line 1038 - 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.
// We want to make sure we 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);
}