You are here

public function SettingsForm::submitForm in Voting API 8.3

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 133

Class

SettingsForm
A form used to configure Voting API settings.

Namespace

Drupal\votingapi\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('votingapi.settings');
  $settings = [
    'anonymous_window',
    'user_window',
    'calculation_schedule',
    'delete_everywhere',
  ];
  foreach ($settings as $setting) {
    $config
      ->set($setting, $form_state
      ->getValue($setting));
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);
}