function _taxonomy_term_select in Drupal 4
Same name and namespace in other branches
- 5 modules/taxonomy/taxonomy.module \_taxonomy_term_select()
- 6 modules/taxonomy/taxonomy.module \_taxonomy_term_select()
2 calls to _taxonomy_term_select()
- taxonomy_form in modules/
taxonomy.module - Generate a form element for selecting terms from a vocabulary.
- taxonomy_form_term in modules/
taxonomy.module
File
- modules/
taxonomy.module, line 1032 - Enables the organization of content into categories.
Code
function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) {
$tree = taxonomy_get_tree($vocabulary_id);
$options = array();
if ($blank) {
$options[0] = $blank;
}
if ($tree) {
foreach ($tree as $term) {
if (!in_array($term->tid, $exclude)) {
$options[$term->tid] = _taxonomy_depth($term->depth, '-') . $term->name;
}
}
if (!$blank && !$value) {
// required but without a predefined value, so set first as predefined
$value = $tree[0]->tid;
}
}
return array(
'#type' => 'select',
'#title' => $title,
'#default_value' => $value,
'#options' => $options,
'#description' => $description,
'#multiple' => $multiple,
'#size' => $multiple ? min(9, count($options)) : 0,
'#weight' => -15,
'#theme' => 'taxonomy_term_select',
);
}