Loading core/modules/workspaces/src/Hook/FormOperations.php +4 −5 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Drupal\Core\Form\WorkspaceDynamicSafeFormInterface; use Drupal\Core\Form\WorkspaceSafeFormInterface; use Drupal\Core\Hook\Attribute\Hook; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Render\Element; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\workspaces\Entity\Workspace; Loading Loading @@ -129,11 +130,9 @@ protected function setAjaxWorkspace(array &$element, array $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'] ?? [], ); if (isset($element['#ajax'])) { $existing_query = $element['#ajax']['options']['query'] ?? []; $element['#ajax']['options']['query'] = NestedArray::mergeDeep($existing_query, $url_query_options); } } Loading core/modules/workspaces/tests/modules/workspaces_test/src/Form/ActiveWorkspaceTestForm.php +11 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,17 @@ public function buildForm(array $form, FormStateInterface $form_state): array { }, ], ]; $form['collision_test'] = [ '#type' => 'textfield', '#ajax' => [ 'url' => Url::fromRoute('workspaces_test.get_form'), 'options' => [ 'query' => [ 'media_library_opener_id' => 'test', ], ], ], ]; return $form; } Loading core/modules/workspaces/tests/src/Kernel/WorkspaceFormPersistenceTest.php +7 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,13 @@ public function testFormPersistence(): void { $form_state_1 = new FormState(); $form_1 = $this->formBuilder->buildForm($form_arg, $form_state_1); $this->assertSame([ 'media_library_opener_id' => 'test', 'workspace' => 'ham', 'token' => $form_1['collision_test']['#ajax']['options']['query']['token'], 'persist' => FALSE, ], $form_1['collision_test']['#ajax']['options']['query']); $this->switchToWorkspace('cheese'); $form_state_2 = new FormState(); $this->formBuilder->buildForm($form_arg, $form_state_2); Loading Loading
core/modules/workspaces/src/Hook/FormOperations.php +4 −5 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Drupal\Core\Form\WorkspaceDynamicSafeFormInterface; use Drupal\Core\Form\WorkspaceSafeFormInterface; use Drupal\Core\Hook\Attribute\Hook; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Render\Element; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\workspaces\Entity\Workspace; Loading Loading @@ -129,11 +130,9 @@ protected function setAjaxWorkspace(array &$element, array $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'] ?? [], ); if (isset($element['#ajax'])) { $existing_query = $element['#ajax']['options']['query'] ?? []; $element['#ajax']['options']['query'] = NestedArray::mergeDeep($existing_query, $url_query_options); } } Loading
core/modules/workspaces/tests/modules/workspaces_test/src/Form/ActiveWorkspaceTestForm.php +11 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,17 @@ public function buildForm(array $form, FormStateInterface $form_state): array { }, ], ]; $form['collision_test'] = [ '#type' => 'textfield', '#ajax' => [ 'url' => Url::fromRoute('workspaces_test.get_form'), 'options' => [ 'query' => [ 'media_library_opener_id' => 'test', ], ], ], ]; return $form; } Loading
core/modules/workspaces/tests/src/Kernel/WorkspaceFormPersistenceTest.php +7 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,13 @@ public function testFormPersistence(): void { $form_state_1 = new FormState(); $form_1 = $this->formBuilder->buildForm($form_arg, $form_state_1); $this->assertSame([ 'media_library_opener_id' => 'test', 'workspace' => 'ham', 'token' => $form_1['collision_test']['#ajax']['options']['query']['token'], 'persist' => FALSE, ], $form_1['collision_test']['#ajax']['options']['query']); $this->switchToWorkspace('cheese'); $form_state_2 = new FormState(); $this->formBuilder->buildForm($form_arg, $form_state_2); Loading