function micon_menu_menu_ui_form_node_form_submit in Micon 8
Same name and namespace in other branches
- 2.x micon_menu/micon_menu.module \micon_menu_menu_ui_form_node_form_submit()
Form submission handler for menu item field on the node form.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
See also
menu_ui_form_node_form_submit()
1 string reference to 'micon_menu_menu_ui_form_node_form_submit'
- micon_menu_form_node_form_alter in micon_menu/
micon_menu.module - Implements hook_form_BASE_FORM_ID_alter().
File
- micon_menu/
micon_menu.module, line 114 - Contains micon_menu.module.
Code
function micon_menu_menu_ui_form_node_form_submit(array $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;
}
_micon_menu_menu_ui_node_save($node, $values);
}
}
}