diff --git a/web/modules/mof/src/Form/ModelSearchForm.php b/web/modules/mof/src/Form/ModelSearchForm.php index 13745ab..ed62f0c 100644 --- a/web/modules/mof/src/Form/ModelSearchForm.php +++ b/web/modules/mof/src/Form/ModelSearchForm.php @@ -30,11 +30,9 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, string $collection_name = NULL) { + public function buildForm(array $form, FormStateInterface $form_state) { $req = $this->request; - $form['collection'] = $collection_name; - $form['search'] = [ '#type' => 'details', '#title' => $this->t('Search filters'), @@ -95,14 +93,14 @@ public function submitForm(array &$form, FormStateInterface $form_state) { unset($query['org']); } - $form_state->setRedirect($form['collection'], $query); + $form_state->setRedirect($this->request->attributes->get('_route'), $query); } /** * Reset the form. */ public function resetForm(array $form, FormStateInterface $form_state) { - $form_state->setRedirect($form['collection']); + $form_state->setRedirect($this->request->attributes->get('_route')); } } diff --git a/web/modules/mof/src/ModelAdminListBuilder.php b/web/modules/mof/src/ModelAdminListBuilder.php index 4d20422..faf0908 100644 --- a/web/modules/mof/src/ModelAdminListBuilder.php +++ b/web/modules/mof/src/ModelAdminListBuilder.php @@ -153,12 +153,23 @@ public function render(): array|RedirectResponse { $build = parent::render(); $build['#attached']['library'][] = 'mof/model-list'; - $build['search'] = $this->formBuilder->getForm('\Drupal\mof\Form\ModelSearchForm', 'entity.model.admin_collection'); + $build['search'] = $this->formBuilder->getForm('\Drupal\mof\Form\ModelSearchForm'); $build['search']['#weight'] = -100; $build['table']['#attributes']['class'][] = 'tablesaw'; $build['table']['#attributes']['class'][] = 'tablesaw-stack'; $build['table']['#attributes']['data-tablesaw-mode'] = 'stack'; + $build['#cache'] = [ + 'contexts' => [ + 'url.query_args:label', + 'url.query_args:org', + 'url.query_args:page', + 'url.query_args:limit', + 'url.query_args:sort', + 'url.query_args:order', + ], + ]; + return $build; } diff --git a/web/modules/mof/src/ModelListBuilder.php b/web/modules/mof/src/ModelListBuilder.php index ee854cc..9ee47ad 100644 --- a/web/modules/mof/src/ModelListBuilder.php +++ b/web/modules/mof/src/ModelListBuilder.php @@ -71,12 +71,23 @@ public function render(): array|RedirectResponse { $build = parent::render(); $build['#attached']['library'][] = 'mof/model-list'; - $build['search'] = $this->formBuilder->getForm('\Drupal\mof\Form\ModelSearchForm', 'entity.model.collection'); + $build['search'] = $this->formBuilder->getForm('\Drupal\mof\Form\ModelSearchForm'); $build['search']['#weight'] = -100; $build['table']['#attributes']['class'][] = 'tablesaw'; $build['table']['#attributes']['class'][] = 'tablesaw-stack'; $build['table']['#attributes']['data-tablesaw-mode'] = 'stack'; + $build['#cache'] = [ + 'contexts' => [ + 'url.query_args:label', + 'url.query_args:org', + 'url.query_args:page', + 'url.query_args:limit', + 'url.query_args:sort', + 'url.query_args:order', + ], + ]; + return $build; }