function SimpletestSettingsForm::validateForm

Overrides FormBase::validateForm

File

core/modules/simpletest/src/Form/SimpletestSettingsForm.php, line 94

Class

SimpletestSettingsForm
Configure simpletest settings for this site.

Namespace

Drupal\simpletest\Form

Code

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.