You are here

function cami_menu_link_content_form_submit in Custom Active Menu Item 8

Submit function for menu add / edit form.

1 string reference to 'cami_menu_link_content_form_submit'
cami_form_menu_link_content_menu_link_content_form_alter in ./cami.module
Implements hook_form_FORM_ID_alter() for menu_link_edit().

File

./cami.module, line 32

Code

function cami_menu_link_content_form_submit($form, FormStateInterface $form_state) {
  $menu_link = $form_state
    ->getFormObject()
    ->getEntity();
  $options = [
    'cami' => $form_state
      ->getValue('cami'),
  ];
  $menu_link_options = $menu_link->link
    ->first()->options;
  $menu_link->link
    ->first()->options = array_merge($menu_link_options, $options);
  $menu_link
    ->save();
}