You are here

function _term_reference_tree_build_level in Taxonomy Term Reference Tree Widget 8

Same name and namespace in other branches
  1. 7.2 term_reference_tree.widget.inc \_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.

2 calls to _term_reference_tree_build_level()
CheckboxTree::processCheckboxTree in src/Element/CheckboxTree.php
Processes a checkboxes form element.
_term_reference_tree_build_item in ./term_reference_tree.module
Builds a single item in the term reference tree widget.

File

./term_reference_tree.module, line 306

Code

function _term_reference_tree_build_level($element, $term, $form_state, $value, $max_choices, $parent_tids, $depth) {
  $start_minimized = TRUE;
  $leaves_only = FALSE;
  $container = [
    '#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 $child) {
    $container[$child->tid] = _term_reference_tree_build_item($element, $child, $form_state, $value, $max_choices, $parent_tids, $container, $depth);
  }
  return $container;
}