Bit of a weird scenario here. I have a form with multiple inputs, when an input is changed, a Stimulus controller triggers “.requestSubmit()” on the form. The form has the following data attributes on it:
turbo_frame: “object-listing”, turbo_action: “advance”
This makes sure that the
object-listing frame gets updates with the results of the form submission and the advance attribute updates the URL and places, as a query string, the filled in form fields.
It all basically works as a filter system to filter items in a grid below.
I’ve hit an issue where I have a filter input in the form of a select field, in this case a
multiple one. When the URL gets advanced, the URL parameters look like the following:
Obviously, in my Rails controller when I am checking if the
attributes parameter exists, I only end up with
Brakes and I don’t see
Tilt. Ideally, I’d like each option selected in the multi-select to show up in a concatenated form such as:
Then the parameter would be
Tilt|Brakesand I can easily split on the
| character and grab what I need from the database.
I have tried modifying the FormData object before
.requestSubmit() is called. I can get this output, BUT, on submission, the URL still shows the original format and hence the filter fails.