Skip to content
Advertisement

how to append `request()->input()` to GET form action

I have a filtration page to get the posts according to user choices, I want to give the user the ability to choose multiple ways to filter, such as the price, post date, category, …etc. therefore I should append the user’s previous choices.

for example ex: example.com?category=1 and now the user wants to filter with price, it should be. ex: example.com?category=1&price=200

it works for me while trying <a></a> tag, ex <a href="{{ route('posts', array_merge(request()->input(), ['price' => 200])) }}">price 200</a>.

so I need to do the same with form GET, here’s how I tries to solve it:

JavaScript

but it doesn’t work, it always removes all parameters and append-only the parameter for the form input

Advertisement

Answer

you should modify:

checkbox name :specialism[] and condition: in_array($specialism->id, request('specialism'))

to be :

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement