public function SettingsForm::validateForm in Swift Mailer 8
Same name and namespace in other branches
- 8.2 src/Form/SettingsForm.php \Drupal\swiftmailer\Form\SettingsForm::validateForm()
Form validation 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 FormBase::validateForm
File
- src/
Form/ SettingsForm.php, line 296
Class
- SettingsForm
- Swift Mailer settings form.
Namespace
Drupal\swiftmailer\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->getValue([
'transport',
'type',
]) == SWIFTMAILER_TRANSPORT_SMTP) {
if ($form_state
->getValue([
'transport',
'configuration',
SWIFTMAILER_TRANSPORT_SMTP,
'credential_provider',
]) == 'swiftmailer') {
if (empty($form_state
->getValue([
'transport',
'configuration',
SWIFTMAILER_TRANSPORT_SMTP,
'credentials',
'swiftmailer',
'password',
]))) {
$password = $this
->config('swiftmailer.transport')
->get('smtp_credentials.swiftmailer.password');
$form_state
->setValue([
'transport',
'configuration',
SWIFTMAILER_TRANSPORT_SMTP,
'credentials',
'swiftmailer',
'password',
], $password);
}
if ($form_state
->getValue([
'transport',
'configuration',
SWIFTMAILER_TRANSPORT_SMTP,
'credentials',
'swiftmailer',
'delete_password',
])) {
$form_state
->setValue([
'transport',
'configuration',
SWIFTMAILER_TRANSPORT_SMTP,
'credentials',
'swiftmailer',
'password',
], NULL);
}
$form_state
->unsetValue([
'transport',
'configuration',
SWIFTMAILER_TRANSPORT_SMTP,
'credentials',
'swiftmailer',
'delete_password',
]);
}
}
}