function _hs_taxonomy_hierarchical_select_terms_to_options in Hierarchical Select 7.3
Same name and namespace in other branches
- 5.3 modules/hs_taxonomy.module \_hs_taxonomy_hierarchical_select_terms_to_options()
- 6.3 modules/hs_taxonomy.module \_hs_taxonomy_hierarchical_select_terms_to_options()
Transform an array of terms into an associative array of options, for use in a select form item.
Parameters
$terms: An array of term objects.
Return value
An associative array of options, keys are tids, values are term names.
2 calls to _hs_taxonomy_hierarchical_select_terms_to_options()
- hs_taxonomy_hierarchical_select_children in modules/
hs_taxonomy.module - Implementation of hook_hierarchical_select_children().
- hs_taxonomy_hierarchical_select_root_level in modules/
hs_taxonomy.module - Implementation of hook_hierarchical_select_root_level().
File
- modules/
hs_taxonomy.module, line 1262 - Implementation of the Hierarchical Select API for the Taxonomy module.
Code
function _hs_taxonomy_hierarchical_select_terms_to_options($terms) {
$options = array();
$use_i18n = module_exists('i18n_taxonomy');
foreach ($terms as $key => $term) {
// Use the translated term when available!
$options[$term->tid] = $use_i18n && isset($term->vid) ? i18n_taxonomy_term_name($term) : $term->name;
}
return $options;
}