public function ViewAddForm::validateForm in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views_ui/src/ViewAddForm.php \Drupal\views_ui\ViewAddForm::validateForm()
- 9 core/modules/views_ui/src/ViewAddForm.php \Drupal\views_ui\ViewAddForm::validateForm()
File
- core/
modules/ views_ui/ src/ ViewAddForm.php, line 163
Class
- ViewAddForm
- Form controller for the Views add form.
Namespace
Drupal\views_uiCode
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);
}
}
}