You are here

public function ConfigForm::submitForm in Private Message 8.2

Same name and namespace in other branches
  1. 8 src/Form/ConfigForm.php \Drupal\private_message\Form\ConfigForm::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/ConfigForm.php, line 229

Class

ConfigForm
Defines the configuration form for the private message module.

Namespace

Drupal\private_message\Form

Code

public function submitForm(array &$form, FormStateInterface $formState) {
  $this
    ->config('private_message.settings')
    ->set('enable_notifications', (bool) $formState
    ->getValue('enable_notifications'))
    ->set('notify_by_default', (bool) $formState
    ->getValue('notify_by_default'))
    ->set('notify_when_using', (string) $formState
    ->getValue('notify_when_using'))
    ->set('number_of_seconds_considered_away', (int) $formState
    ->getValue('number_of_seconds_considered_away'))
    ->set('hide_form_filter_tips', (bool) $formState
    ->getValue('hide_form_filter_tips'))
    ->set('hide_recipient_field_when_prefilled', (bool) $formState
    ->getValue('hide_recipient_field_when_prefilled'))
    ->set('create_message_label', $formState
    ->getValue('create_message_label'))
    ->set('save_message_label', $formState
    ->getValue('save_message_label'))
    ->set('autofocus_enable', (bool) $formState
    ->getValue('autofocus_enable'))
    ->set('keys_send', $formState
    ->getValue('keys_send'))
    ->set('remove_css', (bool) $formState
    ->getValue('remove_css'))
    ->save();
  $definitions = $this->privateMessageConfigFormManager
    ->getDefinitions();
  foreach ($definitions as $definition) {
    $instance = $this->privateMessageConfigFormManager
      ->createInstance($definition['id']);
    $instance
      ->submitForm($formState
      ->getValue($instance
      ->getId()));
  }
  parent::submitForm($form, $formState);
}