You are here

function content_taxonomy_options_groups in Content Taxonomy 5

helper function to generate opt groups in selects

1 call to content_taxonomy_options_groups()
content_taxonomy_options_widget in ./content_taxonomy_options.module
Implementation of hook_widget().

File

./content_taxonomy_options.module, line 207
Defines a widget type for content_taxonomy for options

Code

function content_taxonomy_options_groups($field) {
  $parent = $field['tid'];
  $group_parent = $field['widget']['group_tid'];
  if (!$field['multiple']) {
    $options[0] = t('---');
  }

  //if children in no group
  $default_terms = taxonomy_get_children($parent);
  foreach ($default_terms as $default_term) {
    $options[$default_term->tid] = $default_term->name;
  }
  foreach (taxonomy_get_children($group_parent) as $group) {
    foreach (taxonomy_get_children($group->tid) as $term) {
      $options[$group->name][$term->tid] = $term->name;
      unset($options[$term->tid]);
    }
  }
  return $options;
}