You are here

public function SettingsForm::submitForm in Synonyms 2.0.x

Same name in this branch
  1. 2.0.x src/Form/SettingsForm.php \Drupal\synonyms\Form\SettingsForm::submitForm()
  2. 2.0.x modules/synonyms_list_field/src/Form/SettingsForm.php \Drupal\synonyms_list_field\Form\SettingsForm::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/SettingsForm.php, line 140

Class

SettingsForm
Defines a form that configures forms module settings.

Namespace

Drupal\synonyms\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this
    ->config('synonyms.settings')
    ->set('wording_type', $form_state
    ->getValue('wording_type'))
    ->set('wording_type_label', $this
    ->wordingTypeOptions()[$form_state
    ->getValue('wording_type')])
    ->save();
  parent::submitForm($form, $form_state);
  if ($this->widgets) {
    foreach ($this->widgets as $service_id => $service) {
      $this
        ->config('synonyms_' . $service_id . '.settings')
        ->set('default_wording', $form_state
        ->getValue($service_id))
        ->save();
      parent::submitForm($form, $form_state);
    }
  }
}