You are here

public function CommonSettingsPageForm::submitForm in Multiple Registration 8.2

Same name and namespace in other branches
  1. 8 src/Form/CommonSettingsPageForm.php \Drupal\multiple_registration\Form\CommonSettingsPageForm::submitForm()
  2. 3.x src/Form/CommonSettingsPageForm.php \Drupal\multiple_registration\Form\CommonSettingsPageForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ConfigFormBase::submitForm

File

src/Form/CommonSettingsPageForm.php, line 135

Class

CommonSettingsPageForm
Class CommonSettingsPageForm.

Namespace

Drupal\multiple_registration\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $disable_main = $form_state
    ->getValue('disable_main_register_page');
  $enable_redirect_to_user_profile_when_user_logged_in = $form_state
    ->getValue('enable_redirect_to_user_profile_when_user_logged_in');
  $clicked_button = end($form_state
    ->getTriggeringElement()['#parents']);
  switch ($clicked_button) {
    case 'save':
      $this
        ->config('multiple_registration.common_settings_page_form_config')
        ->set('multiple_registration_disable_main', $disable_main)
        ->save();
      $this
        ->config('multiple_registration.common_settings_page_form_config')
        ->set('enable_redirect_to_user_profile_when_user_logged_in', $enable_redirect_to_user_profile_when_user_logged_in)
        ->save();
      $this->routeBuilder
        ->rebuild();
      $this->cacheRender
        ->invalidateAll();
      break;
  }
  $form_state
    ->setRedirect('multiple_registration.multiple_registration_list_index');
}