function FormOperations::addWorkspaceValidation
Same name in this branch
- 11.x core/modules/workspaces/src/FormOperations.php \Drupal\workspaces\FormOperations::addWorkspaceValidation()
Same name in other branches
- 9 core/modules/workspaces/src/FormOperations.php \Drupal\workspaces\FormOperations::addWorkspaceValidation()
- 8.9.x core/modules/workspaces/src/FormOperations.php \Drupal\workspaces\FormOperations::addWorkspaceValidation()
- 10 core/modules/workspaces/src/FormOperations.php \Drupal\workspaces\FormOperations::addWorkspaceValidation()
Adds our validation handler recursively on each element of a form.
Parameters
array &$element: An associative array containing the structure of the form.
1 call to FormOperations::addWorkspaceValidation()
- FormOperations::formAlter in core/
modules/ workspaces/ src/ Hook/ FormOperations.php - Implements hook_form_alter().
File
-
core/
modules/ workspaces/ src/ Hook/ FormOperations.php, line 54
Class
- FormOperations
- Defines a class for reacting to form operations.
Namespace
Drupal\workspaces\HookCode
protected function addWorkspaceValidation(array &$element) : void {
// Recurse through all children and add our validation handler if needed.
foreach (Element::children($element) as $key) {
if (isset($element[$key]) && $element[$key]) {
$this->addWorkspaceValidation($element[$key]);
}
}
if (isset($element['#validate'])) {
$element['#validate'][] = [
static::class,
'validateDefaultWorkspace',
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.