function eck__bundle__field_autocomplete in Entity Construction Kit (ECK) 7
Same name and namespace in other branches
- 7.3 eck.bundle.inc \eck__bundle__field_autocomplete()
- 7.2 eck.bundle.inc \eck__bundle__field_autocomplete()
1 string reference to 'eck__bundle__field_autocomplete'
- eck__entity__menu in ./
eck.entity.inc - This function creates the menu items related to entity administration
File
- ./
eck.bundle.inc, line 320 - All of the menu, pages, and forms related to bundle administration.
Code
function eck__bundle__field_autocomplete($entity_type, $bundle, $string = "") {
$field_label = get_bundle_field_label_info($entity_type, $bundle);
$matches = array();
if ($field_label) {
$field = $field_label['field'];
$language = $field_label['language'];
$delta = $field_label['delta'];
$column = $field_label['column'];
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', $entity_type->name, '=')
->entityCondition('bundle', $bundle->name, '=')
->fieldCondition($field, $column, $string, 'CONTAINS');
$results = $query
->execute();
$entities = entity_load($entity_type->name, array_keys($results[$entity_type->name]));
foreach ($entities as $id => $entity) {
$matches[$id] = $entity->{$field}[$language][$delta][$column];
}
}
drupal_json_output($matches);
}