You are here

public function SendGridReportsSettingsForm::submitForm in SendGrid Integration 8.2

Same name and namespace in other branches
  1. 8 modules/sendgrid_integration_reports/src/Form/SendGridReportsSettingsForm.php \Drupal\sendgrid_integration_reports\Form\SendGridReportsSettingsForm::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

modules/sendgrid_integration_reports/src/Form/SendGridReportsSettingsForm.php, line 129

Class

SendGridReportsSettingsForm
Class for Sendgrid reports settings form.

Namespace

Drupal\sendgrid_integration_reports\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('sendgrid_integration_reports.settings');
  $values = $form_state
    ->getValues();
  $elems = [
    'start_date',
    'end_date',
    'aggregated_by',
  ];
  foreach ($elems as $elem) {
    $config
      ->set($elem, $values[$elem]);
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);

  // Clear the cache since the settings have been changed.
  \Drupal::cache('sendgrid_integration_reports')
    ->deleteAll();
}