menu_ui_form_node_type_form_validate(&$form, FormStateInterface $form_state)
Validate handler for forms with menu options.
See also
menu_ui_form_node_type_form_alter()
File
- core/modules/menu_ui/menu_ui.module, line 442
- Allows administrators to customize the site's navigation menus.
Code
function menu_ui_form_node_type_form_validate(&$form, FormStateInterface $form_state) { $available_menus = array_filter($form_state->getValue('menu_options')); // If there is at least one menu allowed, the selected item should be in // one of them. if (count($available_menus)) { $menu_item_id_parts = explode(':', $form_state->getValue('menu_parent')); if (!in_array($menu_item_id_parts[0], $available_menus)) { $form_state->setErrorByName('menu_parent', t('The selected menu item is not under one of the selected menus.')); } } else { $form_state->setValue('menu_parent', ''); } }
Please login to continue.