public function SimpletestSettingsForm::validateForm in Drupal 8
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
- core/
modules/ simpletest/ src/ Form/ SimpletestSettingsForm.php, line 94
Class
- SimpletestSettingsForm
- Configure simpletest settings for this site.
Namespace
Drupal\simpletest\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('simpletest.settings');
// If a username was provided but a password wasn't, preserve the existing
// password.
if (!$form_state
->isValueEmpty('simpletest_httpauth_username') && $form_state
->isValueEmpty('simpletest_httpauth_password')) {
$form_state
->setValue('simpletest_httpauth_password', $config
->get('httpauth.password'));
}
// If a password was provided but a username wasn't, the credentials are
// incorrect, so throw an error.
if ($form_state
->isValueEmpty('simpletest_httpauth_username') && !$form_state
->isValueEmpty('simpletest_httpauth_password')) {
$form_state
->setErrorByName('simpletest_httpauth_username', $this
->t('HTTP authentication credentials must include a username in addition to a password.'));
}
parent::validateForm($form, $form_state);
}