function ViewsFormMainForm::validateForm

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Form/ViewsFormMainForm.php \Drupal\views\Form\ViewsFormMainForm::validateForm()
  2. 10 core/modules/views/src/Form/ViewsFormMainForm.php \Drupal\views\Form\ViewsFormMainForm::validateForm()
  3. 9 core/modules/views/src/Form/ViewsFormMainForm.php \Drupal\views\Form\ViewsFormMainForm::validateForm()

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 FormInterface::validateForm

File

core/modules/views/src/Form/ViewsFormMainForm.php, line 156

Class

ViewsFormMainForm

Namespace

Drupal\views\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $view = $form_state->getBuildInfo()['args'][0];
  // Call the validation method on every field handler that has it.
  foreach ($view->field as $field) {
    if (method_exists($field, 'viewsFormValidate')) {
      $field->viewsFormValidate($form, $form_state);
    }
  }
  // Call the validate method on every area handler that has it.
  foreach ([
    'header',
    'footer',
  ] as $area) {
    foreach ($view->{$area} as $area_handler) {
      if (method_exists($area_handler, 'viewsFormValidate')) {
        $area_handler->viewsFormValidate($form, $form_state);
      }
    }
  }
}

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