public function SiteSettingsForm::validateForm

public SiteSettingsForm::validateForm(array &$form, FormStateInterface $form_state)

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/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php, line 150

Class

SiteSettingsForm
Provides a form to configure and rewrite settings.php.

Namespace

Drupal\Core\Installer\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $driver = $form_state->getValue('driver');
  $database = $form_state->getValue($driver);
  $drivers = drupal_get_database_types();
  $reflection = new \ReflectionClass($drivers[$driver]);
  $install_namespace = $reflection->getNamespaceName();
  // Cut the trailing \Install from namespace.
  $database['namespace'] = substr($install_namespace, 0, strrpos($install_namespace, '\\'));
  $database['driver'] = $driver;

  $form_state->set('database', $database);
  foreach ($this->getDatabaseErrors($database, $form_state->getValue('settings_file')) as $name => $message) {
    $form_state->setErrorByName($name, $message);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Installer!Form!SiteSettingsForm.php/function/SiteSettingsForm::validateForm/8.1.x