function 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 124
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']) && !isset($element['#ajax']['options']['query']['workspace'])) {
$element['#ajax']['options']['query'] = array_merge_recursive($url_query_options, $element['#ajax']['options']['query'] ?? []);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.