I'm working on a project that is using Sprout Forms not for saving form submissions but as an interface for searching Craft entries. So the idea is after submitting the form, the template performs a Craft entries search based on values of parameters in th query string.
That part's all working fine. What I'm trying to do now is have the form retain the selections from their previous submissions. Anything that only has a single option like plain text fields, single selects and multi selects with only one option chosen are fine. In the querystring, they look something like fields[fieldHandle]=value
and I can get that with craft.app.request.getParam("fields.#{field.handle}")
.
It's multi-selects – categories and tags fields – that I'm having trouble with. For those when more than one option is selected, the querystring looks like fields[fieldHandle]=XXXX&fields[fieldHandle]=YYYY
. So craft.app.request.getParam("fields.#{field.handle}")
only matches the one that appears last.
How do I get the values of every instance that appears in the querystring?