protected function FormOperations::addWorkspaceValidation in Drupal 10
Same name and namespace in other branches
- 8 core/modules/workspaces/src/FormOperations.php \Drupal\workspaces\FormOperations::addWorkspaceValidation()
- 9 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.
File
- core/
modules/ workspaces/ src/ FormOperations.php, line 96
Class
- FormOperations
- Defines a class for reacting to form operations.
Namespace
Drupal\workspacesCode
protected function addWorkspaceValidation(array &$element) {
// 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',
];
}
}