<p><code>craft.app.request.param('fields')</code> 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: <a href="https://cld.agency/blog/multi-faceted-filtering-in-craftcms" rel="nofollow noreferrer">https://cld.agency/blog/multi-faceted-filtering-in-craftcms</a></p>

CC BY-SA 4.0
2024-03-15T09:44:47.947Z
2024-03-15T09:44:47.947Z
James Smith
<p>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.</p>
<p>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 <code>fields[fieldHandle]=value</code> and I can get that with <code>craft.app.request.getParam(&quot;fields.#{field.handle}&quot;)</code>.</p>
<p>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 <code>fields[fieldHandle]=XXXX&amp;fields[fieldHandle]=YYYY</code>. So <code>craft.app.request.getParam(&quot;fields.#{field.handle}&quot;)</code> only matches the one that appears last.</p>
<p>How do I get the values of every instance that appears in the querystring?</p>

<plugin-sproutforms><tags><querystring>
Setting form values based on querystring
# Setting form values based on querystring

(Asked by: username_0 on 2024-03-15)

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?

**Tags:** plugin-sproutforms, tags, querystring


---

## 1 answers

### Answer by username_1 on 2024-03-15. Score: 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>


---

