function FormOperations::setAjaxWorkspace
Same name and namespace in other branches
- 11.x core/modules/workspaces/src/Hook/FormOperations.php \Drupal\workspaces\Hook\FormOperations::setAjaxWorkspace()
Ensures that the current workspace is persisted across AJAX interactions.
Parameters
array &$element: An associative array containing the structure of the form.
array $url_query_options: An array of URL query options used by the query parameter workspace negotiator.
1 call to FormOperations::setAjaxWorkspace()
- FormOperations::formAlter in core/
modules/ workspaces/ src/ Hook/ FormOperations.php - Implements hook_form_alter().
File
-
core/
modules/ workspaces/ src/ Hook/ FormOperations.php, line 125
Class
- FormOperations
- Defines a class for reacting to form operations.
Namespace
Drupal\workspaces\HookCode
protected function setAjaxWorkspace(array &$element, array $url_query_options) : void {
// Recurse through all children if needed.
foreach (Element::children($element) as $key) {
if (isset($element[$key]) && $element[$key]) {
$this->setAjaxWorkspace($element[$key], $url_query_options);
}
}
if (isset($element['#ajax'])) {
$existing_query = $element['#ajax']['options']['query'] ?? [];
$element['#ajax']['options']['query'] = NestedArray::mergeDeep($existing_query, $url_query_options);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.