You are here

public function SendGridSettingsForm::submitForm in SendGrid Integration 8

Same name and namespace in other branches
  1. 8.2 src/Form/SendGridSettingsForm.php \Drupal\sendgrid_integration\Form\SendGridSettingsForm::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/SendGridSettingsForm.php, line 124

Class

SendGridSettingsForm
Class SendGridSettingsForm.

Namespace

Drupal\sendgrid_integration\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('sendgrid_integration.settings');
  if ($this->moduleHandler
    ->moduleExists('key')) {
    $key_name = $form_state
      ->getValue('sendgrid_integration_apikey');
    $config
      ->set('apikey', $key_name);
  }
  else {
    if ($form_state
      ->hasValue('sendgrid_integration_apikey') && !empty($form_state
      ->getValue('sendgrid_integration_apikey'))) {
      $config
        ->set('apikey', $form_state
        ->getValue('sendgrid_integration_apikey'));
    }
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);
}