1 taxonomy.module taxonomy_allowed_values(array $field)

Returns the set of valid terms for a taxonomy field.

Parameters

array $field: The field definition.

Return value

array: The array of valid terms for this field, keyed by term id.

File

core/modules/taxonomy/taxonomy.module, line 1756
Enables the organization of content into categories.

Code

function taxonomy_allowed_values(array $field) {
  $options = array();
  foreach ($field['settings']['allowed_values'] as $tree) {
    if ($vocabulary = taxonomy_vocabulary_load($tree['vocabulary'])) {
      if ($terms = taxonomy_get_tree($vocabulary->machine_name, $tree['parent'])) {
        foreach ($terms as $term) {
          $options[$term->tid] = $term->name;
        }
      }
    }
  }
  return $options;
}