You are here

function responsive_menu_menu_link_content_submit in Responsive and off-canvas menu 8.2

Same name and namespace in other branches
  1. 8.3 responsive_menu.module \responsive_menu_menu_link_content_submit()
  2. 4.4.x responsive_menu.module \responsive_menu_menu_link_content_submit()
  3. 4.0.x responsive_menu.module \responsive_menu_menu_link_content_submit()
  4. 4.1.x responsive_menu.module \responsive_menu_menu_link_content_submit()
  5. 4.3.x responsive_menu.module \responsive_menu_menu_link_content_submit()

Submit handler which stores any flyleft settings.

1 string reference to 'responsive_menu_menu_link_content_submit'
responsive_menu_form_menu_link_content_form_alter in ./responsive_menu.module
Implements hook_form_FORM_ID_alter() for menu_link_content_form().

File

./responsive_menu.module, line 295
Contains procedural code.

Code

function responsive_menu_menu_link_content_submit($form, FormStateInterface $form_state) {

  // Store the flyleft as an option on the menu link entity.
  if ($form_state
    ->getValue('flyleft')) {
    $menu_link = $form_state
      ->getFormObject()
      ->getEntity();
    $options = [
      'attributes' => [
        'flyleft' => TRUE,
      ],
    ];
    $menu_link_options = $menu_link->link
      ->first()->options;
    $menu_link->link
      ->first()->options = array_merge($menu_link_options, $options);
    $menu_link
      ->save();
  }
}