You are here

function menu_link_modal_menu_link_content_form_submit in Menu Link Modal 8.2

Same name and namespace in other branches
  1. 8 menu_link_modal.module \menu_link_modal_menu_link_content_form_submit()

Submit handler for the menu form alter.

1 string reference to 'menu_link_modal_menu_link_content_form_submit'
menu_link_modal_form_menu_link_content_form_alter in ./menu_link_modal.module
Implements hook_form_BASE_FORM_ID_alter().

File

./menu_link_modal.module, line 71
Main file of Menu Link Modal module.

Code

function menu_link_modal_menu_link_content_form_submit($form, FormStateInterface $form_state) {
  $menu_link = $form_state
    ->getFormObject()
    ->getEntity();
  $options = [
    'modal' => [],
  ];
  if ($form_state
    ->getValue('open_modal')) {
    $options['modal'] = [
      'width' => $form_state
        ->getValue('modal_width'),
      'height' => $form_state
        ->getValue('modal_height'),
    ];
  }
  $menu_link_options = $menu_link->link
    ->first()->options;
  $menu_link->link
    ->first()->options = array_merge($menu_link_options, $options);
  $menu_link
    ->save();
}