I have a route that looks like this - route/{parameter} and I need to change the parameter after submitting a form.
I tried to use redirectToRoute but it created new URL together with some other parameters that the form passed which I don't want.
So I would love to ask you if there is some way to redirect to a new URL with the only parameter that I choose through select in the form.
Thank you very much for your responses.
EDIT:
I am going to share more actual information. This is how my controller for the form looks like:
$form = $this->createFormBuilder()
->setMethod("get")
->add('category', ChoiceType::class, [
'choices' => [
'Všechny kategorie' => 'vsechny-kategorie',
'Automobilový průmysl' => 'automobilovy-prumysl',
'Stavebnictví' => 'stavebnictvi',
'Elektronika a elektrotechnika' => 'elektronika-a-elektrotechnika',
'Gastronomie' => 'gastronomie',
'Lesnictví' => 'lesnictvi',
'Potravinářský průmysl' => 'potravinarsky-prumysl',
'IT technologie' => 'it-technologie',
'Logistika' => 'logistika',
'Strojírenství' => 'strojirenstvi',
'Zdravotnictví' => 'zdravotnictvi'
],
'label' => 'Kategorie:'
])
->add('send', SubmitType::class, ['label' => 'Test'])
->getForm();
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$category = $data['category'];
return $this->redirectToRoute('jobs', [
'jobs' => $pagination,
'categoryForm' => $form->createView(),
'category' => $category,
]);
}
$categorya string or is it an object?