In a Symfony 3 application i've a route for the search form with two controllers: one for a head/get request, and one for a post request. I need two controllers as searches can be shared.
Here's my problem: if a user comes to the site from a link with a query string, but then performs a post of the search form ... the query string from the original link he clicked always remains in the url, even after page reload.
So the question is: how can i clear out the query string? I've tried to remove all keys in the query ParameterBag of the request (which seems far-fetched as a way to solve this), but that didn't work.
Here's the code in my controller:
$form = $this->buildSearchForm();
$form->handleRequest($request);
$searchTerm = $form->get('search')->getData();
$types = $this->getTypes($form);
$query = $this->assembleQuery($form);
return $this->render("search/zoekpagina.html.twig", array(
"distance" => $form->get('distance')->getData(),
"form" => $form->createView(),
"results" => $ESquery->searchByType($types, $query, $searchTerm),
"searchTerm" => $searchTerm,
"filters" => true,
));