You are here

function _menu_link_weight_get_parent_value_from_element in Menu Link Weight 8

Same name and namespace in other branches
  1. 8.2 menu_link_weight.module \_menu_link_weight_get_parent_value_from_element()
  2. 7 menu_link_weight.module \_menu_link_weight_get_parent_value_from_element()

Gets the menu link parent value from the form.

Helper function for menu link weight process callback.

Parameters

array $parent_element: Menu link parent form element.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

string Menu link

4 calls to _menu_link_weight_get_parent_value_from_element()
menu_link_weight_menu_link_content_element_process in ./menu_link_weight.menu_ui.inc
Process callback for the menu link weight element.
menu_link_weight_menu_link_content_form_validate in ./menu_link_weight.menu_ui.inc
Validation hook for the menu_link weight element.
menu_link_weight_node_element_process in ./menu_link_weight.node.inc
Process callback for the menu link weight element.
menu_link_weight_node_form_validate in ./menu_link_weight.node.inc
Validation hook for the menu_link weight element.

File

./menu_link_weight.module, line 77
Replaces the menu link weight dropdown with a tabledrag widget.

Code

function _menu_link_weight_get_parent_value_from_element(array $parent_element, FormStateInterface $form_state) {
  if ($form_state
    ->hasValue([
    'menu',
    'menu_parent',
  ])) {
    $value = $form_state
      ->getValue([
      'menu',
      'menu_parent',
    ]);
  }
  else {
    $value = !empty($parent_element['#value']) ? $parent_element['#value'] : $parent_element['#default_value'];
  }
  return $value;
}