function _tac_lite_term_select in Taxonomy Access Control Lite 7
Helper function to build a taxonomy term select element for a form.
Parameters
$v: A vocabulary object containing a vid and name.
$default_values: An array of values to use for the default_value argument for this form element.
2 calls to _tac_lite_term_select()
- tac_lite_admin_scheme_form in ./
tac_lite.module - Returns the form for role-based privileges.
- tac_lite_form_alter in ./
tac_lite.module - Implementation of hook_form_alter().
File
- ./
tac_lite.module, line 606 - Control access to site content based on taxonomy, roles and users.
Code
function _tac_lite_term_select($v, $default_values = array()) {
$tree = taxonomy_get_tree($v->vid);
$options = array(
0 => '<' . t('none') . '>',
);
if ($tree) {
foreach ($tree as $term) {
$choice = new stdClass();
$choice->option = array(
$term->tid => str_repeat('-', $term->depth) . $term->name,
);
$options[] = $choice;
}
}
$field_array = array(
'#type' => 'select',
'#title' => $v->name,
'#default_value' => $default_values,
'#options' => $options,
'#multiple' => TRUE,
'#description' => $v->description,
);
return $field_array;
}