1 taxonomy.module taxonomy_allowed_values($field)

Returns the set of valid terms for a taxonomy field.

Parameters

$field: The field definition.

Return value

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

File

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

Code

function taxonomy_allowed_values($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] = str_repeat('· ', $term->depth) . $term->name;
        }
      }
    }
  }
  return $options;
}