public function SendGridSettingsForm::submitForm in SendGrid Integration 8.2
Same name and namespace in other branches
- 8 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 142
Class
- SendGridSettingsForm
- Class SendGridSettingsForm.
Namespace
Drupal\sendgrid_integration\FormCode
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'));
}
}
if ($form_state
->hasValue('sendgrig_intergration_trackopens') && !empty($form_state
->getValue('sendgrig_intergration_trackopens'))) {
$config
->set('trackopens', 1);
}
elseif (empty($form_state
->getValue('sendgrig_intergration_trackopens'))) {
$config
->set('trackopens', 0);
}
if ($form_state
->hasValue('sendgrig_intergration_trackclicks') && !empty($form_state
->getValue('sendgrig_intergration_trackclicks'))) {
$config
->set('trackclicks', 1);
}
elseif (empty($form_state
->getValue('sendgrig_intergration_trackclicks'))) {
$config
->set('trackclicks', 0);
}
$config
->save();
parent::submitForm($form, $form_state);
}