function menu_ui_form_node_form_submit
Same name in other branches
- 9 core/modules/menu_ui/menu_ui.module \menu_ui_form_node_form_submit()
- 10 core/modules/menu_ui/menu_ui.module \menu_ui_form_node_form_submit()
- 11.x core/modules/menu_ui/menu_ui.module \menu_ui_form_node_form_submit()
Form submission handler for menu item field on the node form.
See also
menu_ui_form_node_form_alter()
1 string reference to 'menu_ui_form_node_form_submit'
- menu_ui_form_node_form_alter in core/
modules/ menu_ui/ menu_ui.module - Implements hook_form_BASE_FORM_ID_alter() for \Drupal\node\NodeForm.
File
-
core/
modules/ menu_ui/ menu_ui.module, line 328
Code
function menu_ui_form_node_form_submit($form, FormStateInterface $form_state) {
$node = $form_state->getFormObject()
->getEntity();
if (!$form_state->isValueEmpty('menu')) {
$values = $form_state->getValue('menu');
if (empty($values['enabled'])) {
if ($values['entity_id']) {
$entity = MenuLinkContent::load($values['entity_id']);
$entity->delete();
}
}
elseif (trim($values['title'])) {
// Decompose the selected menu parent option into 'menu_name' and 'parent',
// if the form used the default parent selection widget.
if (!empty($values['menu_parent'])) {
list($menu_name, $parent) = explode(':', $values['menu_parent'], 2);
$values['menu_name'] = $menu_name;
$values['parent'] = $parent;
}
_menu_ui_node_save($node, $values);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.