$form['#first_tid'
] =
$term->
id();
} // Keep a variable to make sure at least 2 root elements are displayed.
if ($term->parents
[0
] == 0
) { $root_entries++;
} $current_page[$key] =
$term;
} while (isset($tree[++
$tree_index]));
// Because we didn't use a pager query, set the necessary pager variables.
$total_entries =
$before_entries +
$page_entries +
$after_entries;
$this->pagerManager->
createPager($total_entries,
$page_increment);
// If this form was already submitted once, it's probably hit a validation
// error. Ensure the form is rebuilt in the same order as the user
// submitted.
$user_input =
$form_state->
getUserInput();
if (!
empty($user_input['terms'
])) { // Get the POST order.
$order =
array_flip(array_keys($user_input['terms'
]));
// Update our form with the new order.
$current_page =
array_merge($order,
$current_page);
foreach ($current_page as $key =>
$term) {