function ViewAddForm::validateForm

Same name in other branches
  1. 9 core/modules/views_ui/src/ViewAddForm.php \Drupal\views_ui\ViewAddForm::validateForm()
  2. 8.9.x core/modules/views_ui/src/ViewAddForm.php \Drupal\views_ui\ViewAddForm::validateForm()
  3. 11.x core/modules/views_ui/src/ViewAddForm.php \Drupal\views_ui\ViewAddForm::validateForm()

Overrides FormBase::validateForm

File

core/modules/views_ui/src/ViewAddForm.php, line 175

Class

ViewAddForm
Form controller for the Views add form.

Namespace

Drupal\views_ui

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
    $wizard_type = $form_state->getValue([
        'show',
        'wizard_key',
    ]);
    $wizard_instance = $this->wizardManager
        ->createInstance($wizard_type);
    $form_state->set('wizard', $wizard_instance->getPluginDefinition());
    $form_state->set('wizard_instance', $wizard_instance);
    $path =& $form_state->getValue([
        'page',
        'path',
    ]);
    if (!empty($path)) {
        // @todo https://www.drupal.org/node/2423913 Views should expect and store
        //   a leading /.
        $path = ltrim($path, '/ ');
    }
    $errors = $wizard_instance->validateView($form, $form_state);
    foreach ($errors as $display_errors) {
        foreach ($display_errors as $name => $message) {
            $form_state->setErrorByName($name, $message);
        }
    }
}

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