You are here

function entity_metadata_field_term_reference_callback in Entity API 7

Additional callback to adapt the property info for term reference fields.

See also

entity_metadata_field_entity_property_info()

1 string reference to 'entity_metadata_field_term_reference_callback'
entity_field_info_alter in includes/entity.property.inc
Implements hook_field_info_alter(). Defines default property types for core field types.

File

modules/field.info.inc, line 125
Provides info for fields.

Code

function entity_metadata_field_term_reference_callback(&$info, $entity_type, $field, $instance, $field_type) {
  $property =& $info[$entity_type]['bundles'][$instance['bundle']]['properties'][$field['field_name']];
  if (count($field['settings']['allowed_values']) == 1) {
    $settings = reset($field['settings']['allowed_values']);
    $property['bundle'] = $settings['vocabulary'];
  }

  // Only add the options list callback for controlled vocabularies, thus
  // vocabularies not using the autocomplete widget.
  if ($instance['widget']['type'] != 'taxonomy_autocomplete') {
    $property['options list'] = 'entity_metadata_field_options_list';
  }
}