You are here

function _term_reference_tree_build_level in Taxonomy Term Reference Tree Widget 7.2

Same name and namespace in other branches
  1. 8 term_reference_tree.module \_term_reference_tree_build_level()
  2. 7 term_reference_tree.widget.inc \_term_reference_tree_build_level()

Builds a level in the term reference tree widget.

This function returns an element that has a number of checkbox_tree_item elements as children. It is meant to be called recursively when the widget is built.

Parameters

$element: The main checkbox_tree element.

$term: A taxonomy term object. $term->children should be an array of the term objects that are that term's children.

$form_state: The form state.

$value: The value of the element.

$max_choices: The maximum number of allowed selections.

Return value

A completed checkbox_tree_level element.

2 calls to _term_reference_tree_build_level()
term_reference_tree_process_checkbox_tree in ./term_reference_tree.widget.inc
Process the checkbox_tree widget.
_term_reference_tree_build_item in ./term_reference_tree.widget.inc
Builds a single item in the term reference tree widget.

File

./term_reference_tree.widget.inc, line 782

Code

function _term_reference_tree_build_level(&$element, &$term, &$form_state, &$value, $max_choices, $parent_tids, $depth) {
  $start_minimized = FALSE;
  if (array_key_exists('#start_minimized', $element)) {
    $start_minimized = $element['#start_minimized'];
  }
  $leaves_only = FALSE;
  if (array_key_exists('#leaves_only', $element)) {
    $leaves_only = $element['#leaves_only'];
  }
  $container = array(
    '#type' => 'checkbox_tree_level',
    '#max_choices' => $max_choices,
    '#leaves_only' => $leaves_only,
    '#start_minimized' => $start_minimized,
    '#depth' => $depth,
  );
  $container['#level_start_minimized'] = $depth > 1 && $element['#start_minimized'] && !$term->children_selected;
  foreach ($term->children as $t) {
    $container[$t->tid] = _term_reference_tree_build_item($element, $t, $form_state, $value, $max_choices, $parent_tids, $container, $depth);
  }
  return $container;
}