You are here

function _domain_menus_menu_form_submit in Domain Menus for Domains 9.1.x

Same name and namespace in other branches
  1. 9.x domain_menus.module \_domain_menus_menu_form_submit()
  2. 3.x domain_menus.module \_domain_menus_menu_form_submit()

Helper function to save third party settings on form submit.

1 string reference to '_domain_menus_menu_form_submit'
domain_menus_form_alter in ./domain_menus.module
Implements hook_form_alter().

File

./domain_menus.module, line 70
Domain menus implementation through entity create, delete, and access customizations.

Code

function _domain_menus_menu_form_submit($form, FormStateInterface &$form_state) {
  $menu = $form_state
    ->getFormObject()
    ->getEntity();

  // filter out unchecked options
  $values = array_diff($form_state
    ->getValue('domain_menus_menu_domains'), array(
    '0',
  ));
  if (!empty($values)) {
    $menu
      ->setThirdPartySetting('domain_menus', 'domains', $values);
  }
  else {
    $menu
      ->unsetThirdPartySetting('domain_menus', 'domains');
  }
  $menu
    ->save();
}