function 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/ FormOperations.php - Alters forms to disallow editing in non-default workspaces.
File
-
core/
modules/ workspaces/ src/ FormOperations.php, line 86
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',
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.