From 0aacc44c2fbdccda95c5955faa6b9bf8b24b84b0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 15 Oct 2020 10:35:20 +0200 Subject: [PATCH] Controller: Set redirect url for the search bar in `Form::ON_SENT` --- library/Icingadb/Web/Controller.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/Icingadb/Web/Controller.php b/library/Icingadb/Web/Controller.php index 4cf936ce..7205c32d 100644 --- a/library/Icingadb/Web/Controller.php +++ b/library/Icingadb/Web/Controller.php @@ -147,7 +147,7 @@ class Controller extends CompatController )); } - $searchBar->on(SearchBar::ON_SUCCESS, function (SearchBar $form) use ($requestUrl) { + $searchBar->on(SearchBar::ON_SENT, function (SearchBar $form) use ($requestUrl) { $existingParams = $requestUrl->getParams(); $requestUrl->setQueryString($form->getFilter()->toQueryString()); foreach ($existingParams->toArray(false) as $name => $value) { @@ -159,7 +159,9 @@ class Controller extends CompatController $requestUrl->getParams()->addEncoded($name, $value); } - $this->getResponse()->redirectAndExit($requestUrl); + $form->setRedirectUrl($requestUrl); + })->on(SearchBar::ON_SUCCESS, function (SearchBar $form) { + $this->getResponse()->redirectAndExit($form->getRedirectUrl()); })->handleRequest(ServerRequest::fromGlobals()); Html::tag('div', ['class' => 'filter'])->wrap($searchBar);