You are here

public static function MenuSelectTree::validateMenuSelectTree in Menu Select 2.0.x

Same name and namespace in other branches
  1. 8 src/Element/MenuSelectTree.php \Drupal\menu_select\Element\MenuSelectTree::validateMenuSelectTree()

Validate the element.

Setting the form state value, in addition to ::valueCallback is required for this element to return a single string, instead of an array.

File

src/Element/MenuSelectTree.php, line 116

Class

MenuSelectTree
A form element for the select tree.

Namespace

Drupal\menu_select\Element

Code

public static function validateMenuSelectTree(&$element, FormStateInterface $form_state, &$complete_form) {
  $input_exists = FALSE;
  $input = NestedArray::getValue($form_state
    ->getValues(), $element['#parents'], $input_exists);
  if ($input_exists) {
    $form_state
      ->setValueForElement($element, $input['tree']['menu_parent_id']);
  }
}