You are here

function _term_reference_tree_flatten in Taxonomy Term Reference Tree Widget 7

Same name and namespace in other branches
  1. 8 term_reference_tree.module \_term_reference_tree_flatten()
  2. 7.2 term_reference_tree.module \_term_reference_tree_flatten()

Recursively go through the option tree and return a flat array of options

1 call to _term_reference_tree_flatten()
_term_reference_tree_widget_validate in ./term_reference_tree.widget.inc
Validates the term reference tree widgets.

File

./term_reference_tree.module, line 249

Code

function _term_reference_tree_flatten($element, &$form_state) {
  $output = array();
  $children = element_children($element);
  foreach ($children as $c) {
    $child = $element[$c];
    if (array_key_exists('#type', $child) && ($child['#type'] == 'radio' || $child['#type'] == 'checkbox')) {
      $output[] = $child;
    }
    else {
      $output = array_merge($output, _term_reference_tree_flatten($child, $form_state));
    }
  }
  return $output;
}