M
M
Mikhail A.2021-02-25 13:54:13
Laravel
Mikhail A., 2021-02-25 13:54:13

Product filter in Laravel (checkboxes)?

There is a filter of goods, which is not yet possible to bring to mind. The filter uses multiple checkboxes with the same name. And if you mark several checkboxes, then the value is taken only from the last one.

The problem seems to be solved by adding [], but then the address bar becomes not at all beautiful:

/catalog?diagonal=27"&diagonal=32"

I would like it to be like this:
/catalog?diagonal=27"|32"

I managed to do it so that such an address bar works (for this, the [] was removed from name). However, this only works through the address bar. How to make such an address bar formed by clicking on checkboxes and submitting the form?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2021-02-25
@Fragster

It is very easy to make a hidden field, the value of which will be formed by js from the checkboxes, using vue. It turns out that we need a component that takes an array of checkboxes as input, renders checkboxes and a hidden input.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question