function taxonomy_allowed_values

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

modules/taxonomy/taxonomy.module, line 1652
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_machine_name_load($tree['vocabulary'])) {
      if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'])) {
        foreach ($terms as $term) {
          $options[$term->tid] = str_repeat('-', $term->depth) . $term->name;
        }
      }
    }
  }
  return $options;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.module/function/taxonomy_allowed_values/7.x