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?

1 Answer 1


craft.app.request.param('fields') will give you back an array of all the values. Not sure exactly what your use case is or why you're using Sprout Forms for it, but it sounds like you might benefit from some parts of my article on front-end filtering here: https://cld.agency/blog/multi-faceted-filtering-in-craftcms

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.