public function SimpletestSettingsForm::validateForm

Implements \Drupal\Core\Form\FormInterface::validateForm().

Overrides SystemConfigFormBase::validateForm

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestSettingsForm.php, line 88
Contains \Drupal\simpletest\Form\SimpletestSettingsForm.

Class

SimpletestSettingsForm
Configure simpletest settings for this site.

Namespace

Drupal\simpletest\Form

Code

public function validateForm(array &$form, array &$form_state) {
  $config = $this->configFactory
    ->get('simpletest.settings');

  // If a username was provided but a password wasn't, preserve the existing
  // password.
  if (!empty($form_state['values']['simpletest_httpauth_username']) && empty($form_state['values']['simpletest_httpauth_password'])) {
    $form_state['values']['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 (empty($form_state['values']['simpletest_httpauth_username']) && !empty($form_state['values']['simpletest_httpauth_password'])) {
    form_set_error('simpletest_httpauth_username', t('HTTP authentication credentials must include a username in addition to a password.'));
  }
  parent::validateForm($form, $form_state);
}