Answers.Body: <p>To get this working, you will need to find a way to continue passing all of your form’s values to each of the additional pages.</p>
  
  <p>There are a few ways you could do that, but the easiest and best option is to change your search form’s <code>method</code> attribute to <code>"get"</code> rather than <code>"post"</code>.</p>
  
  <pre><code>&lt;form method="get"&gt;
  </code></pre>
  
  <p><em>(Side note: there’s no need to add <code>action=""</code> – the default browser behavior if that attribute is omitted is for the form to submit to the current URL.)</em></p>
  
  <p>Now when you submit your form you will see all of the form values show up in the resulting page’s query string. While that’s not quite as nice-looking, its advantages outweigh the ugly: browsers won’t ask users if they are sure they want to resubmit a form when they click the Back/Forward buttons, and the URLs will be sharable.</p>
  
  <p>The next step is to update your pagination links to include the query string, which will effectively pass on the form’s values between each of the pages. We’ll use <a href="http://buildwithcraft.com/docs/templating/craft.request#getQueryStringWithoutPath">craft.request.getQueryStringWithoutPath()</a> for that:</p>
  
  <pre><code>{% set qs = '?' ~ craft.request.getQueryStringWithoutPath() %}
  
  &lt;li&gt;&lt;a href="{{ paginate.firstUrl ~ qs }}" title="First Page"&gt;&amp;laquo;&lt;/a&gt;&lt;/li&gt;
  {% if paginate.prevUrl %}
     &lt;li&gt;&lt;a href="{{ paginate.prevUrl ~ qs }}" title="Previous Page"&gt;&amp;lsaquo;&lt;/a&gt;&lt;/li&gt;
  {% endif %}
  {% for page, url in paginate.getPrevUrls(4) %}
     &lt;li&gt;&lt;a href="{{ url ~ qs }}" title="Page {{ page }}"&gt;{{ page }}&lt;/a&gt;
  {% endfor %}
  &lt;li class="current"&gt;&lt;a href="" title="Page {{ paginate.currentPage }}"&gt;{{ paginate.currentPage }}&lt;/a&gt;&lt;/li&gt;
  {% for page, url in paginate.getNextUrls(4) %}
     &lt;li&gt;&lt;a href="{{ url ~ qs }}" title="Page {{ page }}"&gt;{{ page }}&lt;/a&gt;
  {% endfor %}
  {% if paginate.nextUrl %}
     &lt;li&gt;&lt;a href="{{ paginate.nextUrl ~ qs }}" title="Next Page"&gt;&amp;rsaquo;&lt;/a&gt;&lt;/li&gt;
  {% endif %}
  &lt;li&gt;&lt;a href="{{ paginate.lastUrl ~ qs }}" title="Last Page"&gt;&amp;raquo;&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-27T18:34:06.270Z
Answers.LastActivityDate: 2015-01-27T18:34:06.270Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I have a search form containing 1 text field and 2 checkbox groups.</p>
  
  <p>Text field is called: <code>keywords</code> and the checkbox groups are called: <code>services[]</code> and <code>locations[]</code>.</p>
  
  <p>The search works fine if I don't try to pagination the results.</p>
  
  <p>When I try to paginate the results, say I set the limit to 9 entries per page, my first page has the 9 entries listed and I get next page link to go to page 2 but when I click the next page link, I don't get the 2nd page as expected. The results have cleared? Page "reset".</p>
  
  <p>How can I paginate my form containing multiple fields?</p>
  
  <p>I have already tried <code>craft.request.getQueryStringWithoutPath()</code>, the "solution" in another question but it does not work for me with checkbox groups as my 2 other form fields.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>{% set services = craft.categories.group("services").status("live").find() %}
  {% set locations = craft.categories.group("locations").status("live").find() %}
  
  {% set queryKeywords = craft.request.getParam("keywords") | trim %}
  {% set queryServices = craft.request.getParam("services") %}
  {% set queryLocations = craft.request.getParam("locations") %}
  
  &lt;form action="" method="POST"&gt;
      &lt;input type="text" name="keywords" value=""&gt;
      {% if services | length %}
          {% for service in services %}
          &lt;label&gt;{{ service.title }}&lt;input type="checkbox" name="services[]" value="{{ service.slug }}" /&gt;&lt;/label&gt;
          {% endfor %}
      {% endif %}
      {% if locations | length %}
          {% for location in locations %}
          &lt;label&gt;{{ location.title }} &lt;input type="checkbox" name="locations[]" value="{{ location.slug }}"/&gt;&lt;/label&gt;                                     
          {% endfor %}
      {% endif %}
      &lt;button type="submit"&gt;Refine&lt;/button&gt;
  &lt;/form&gt;
  
  
  
  
  {% set originalKeywords = craft.request.getParam("keywords") | trim %}
  {% set keywords = originalKeywords | replace({ "*" : "" }) %}
  {% set services = craft.request.getParam("services") %}
  {% set locations = craft.request.getParam("locations") %}
  
  {% if (keywords | length) or (services | length) or (locations | length) %}
      {% set relatedTo = ["and"] %}
  
  
      {% set serviceCategoryIds = [] %}
      {% set locationCategoryIds = [] %}
  
  
      {% set serviceCategories = craft.categories.group("services") %}
      {% set locationCategories = craft.categories.group("locations") %}
  
  
      {% set servicesCategories = services | join(", ") | trim %}
      {% if services | length %}
          {% for service in services %}
              {% set serviceCategoryIds = serviceCategories.slug(servicesCategories).ids() %}
          {% endfor %}
      {% endif %}
      {% if serviceCategoryIds | length %}
          {% for serviceCategoryId in serviceCategoryIds %}
              {% set relatedTo = relatedTo | merge([serviceCategoryId]) %}
          {% endfor %}
      {% endif %}
  
  
      {% set locationsCategories = locations | join(", ") | trim %}
      {% if locations | length %}
          {% for location in locations %}
              {% set locationCategoryIds = locationCategories.slug(locationsCategories).ids() %}
          {% endfor %}
      {% endif %}
      {% if locationCategoryIds | length %}
          {% for locationCategoryId in locationCategoryIds %}
              {% set relatedTo = relatedTo | merge([locationCategoryId]) %}
          {% endfor %}
      {% endif %}
  
  
      {% set keywords = "*" ~ keywords | replace({ " " : "* *" }) ~ "*" %}
  
  
      {% set allMembers = craft.users.group("members").status("live").search(keywords).order("score") %}
  
  
      {% if (relatedTo | length) &gt; 1 %}
          {% set allMembers = allMembers.relatedTo(relatedTo) %}
      {% endif %}
  
  
      &lt;h3&gt;{{ allMembers | length }} Result{% if (allMembers | length) == 1 %}{% else %}s{% endif %}&lt;/h3&gt;
  
  
      {% if allMembers | length %}
          {% paginate allMembers as members %}
  
              &lt;ul&gt;
                  {% for member in members %}
                  &lt;li&gt;{{ member.fullName }}&lt;/li&gt;
                  {% endfor %}
              &lt;/ul&gt;
  
              {% if paginate.totalPages &gt; 1 %}
              &lt;ul&gt;
                  &lt;li&gt;&lt;a href="{{ paginate.firstUrl }}" title="First Page"&gt;&amp;laquo;&lt;/a&gt;&lt;/li&gt;
                  {% if paginate.prevUrl %}&lt;li&gt;&lt;a href="{{ paginate.prevUrl }}" title="Previous Page"&gt;&amp;lsaquo;&lt;/a&gt;&lt;/li&gt;{% endif %}
                  {% for page, url in paginate.getPrevUrls(4) %}
                  &lt;li&gt;&lt;a href="{{ url }}" title="Page {{ page }}"&gt;{{ page }}&lt;/a&gt;
                  {% endfor %}
                  &lt;li class="current"&gt;&lt;a href="" title="Page {{ paginate.currentPage }}"&gt;{{ paginate.currentPage }}&lt;/a&gt;&lt;/li&gt;
                  {% for page, url in paginate.getNextUrls(4) %}
                  &lt;li&gt;&lt;a href="{{ url }}" title="Page {{ page }}"&gt;{{ page }}&lt;/a&gt;
                  {% endfor %}
                  {% if paginate.nextUrl %}&lt;li&gt;&lt;a href="{{ paginate.nextUrl }}" title="Next Page"&gt;&amp;rsaquo;&lt;/a&gt;&lt;/li&gt;{% endif %}
                  &lt;li&gt;&lt;a href="{{ paginate.lastUrl }}" title="Last Page"&gt;&amp;raquo;&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
              {% endif %}
  
          {% endpaginate %}
  
      {% else %}
          &lt;p&gt;Your search didn&amp;#39;t return any members.&lt;/p&gt;
      {% endif %}
  
  {% endif %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-20T08:09:02.733Z
Comments.Text: Marion, the question titled "How to paginate search results?" only uses a query param. My question is related to using a form with multiple fields so the solution in "How to paginate search results?" doesn't work for me.
Comments.UserDisplayName: Sean Delaney
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-20T17:54:41.537Z
Comments.Text: Hi Sean, can you edit your question and add some of your existing code? That will help us figure out exactly what needs to be changed, and also shed some light as to why this question is not a duplicate.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-22T09:31:36.777Z
Comments.Text: I've added my existing code. My question is not a duplicate. Is are no other questions posted that has 3 form fields and paginates that search results. All previous posts only have 1 form field and the solutions in those questions don't work for me.
Comments.UserDisplayName: Sean Delaney
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-27T10:33:23.727Z
Comments.Text: Guys, please read my comments above - the solutions in these other questions do not work for me. Why are you still marking this question as a duplicate! Can you please explain why? All I want is a solution to **my issue**, which are **not** the same as these other questions! These other solutions only use 1 form field, I am using 3 form fields and pagination is not working.
Comments.UserDisplayName: Sean Delaney
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-27T11:05:44.467Z
Comments.Text: It's very frustrating when everyone jumps on the "duplicate" bandwagon. It's like no one is fully reading my question and comments, realising the difference between mine and this other question (http://craftcms.stackexchange.com/questions/644/how-to-paginate-search-results).
Comments.UserDisplayName: Sean Delaney
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-27T11:26:16.027Z
Comments.Text: This is clearly not the same problem, please read the question properly before marking as a duplicate.
Comments.UserDisplayName: Ian Nebbiolo
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-27T16:07:27.703Z
Comments.Text: Sean, what's the URL you are getting on page 2 for `{% paginate entries.limit(9) as paginatedEntries %}` and a link `<a href="{{ paginate.nextUrl }}?{{ craft.request.getQueryStringWithoutPath() }}">&rsaquo;</a>`?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-27T16:21:58.270Z
Comments.Text: Ahhh... you're sending the form data using `method="POST"`. This can't work with the suggested "solutions". Remove this or change to `method="GET"` as a temporary fix.
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-27T17:38:52.520Z
Comments.Text: @SeanDelaney Don't get too frustrated... everyone is doing what they can on a site like this. It can be challenging to follow the minutia of a question's specific details because we can't see the code and aren't absorbing all the details.
Comments.UserDisplayName: Anna_MediaGirl
Tags: <pagination>
Title: Search Results Pagination with multiple form fields
ThreadText: # Search Results Pagination with multiple form fields
  
  (Asked by: username_0 on 2015-01-19)
  
  I have a search form containing 1 text field and 2 checkbox groups.
  
  Text field is called: `keywords` and the checkbox groups are called: `services[]` and `locations[]`.
  
  The search works fine if I don't try to pagination the results.
  
  When I try to paginate the results, say I set the limit to 9 entries per page, my first page has the 9 entries listed and I get next page link to go to page 2 but when I click the next page link, I don't get the 2nd page as expected. The results have cleared? Page "reset".
  
  How can I paginate my form containing multiple fields?
  
  I have already tried `craft.request.getQueryStringWithoutPath()`, the "solution" in another question but it does not work for me with checkbox groups as my 2 other form fields.
  
  Here is my code:
  
  ```
  {% set services = craft.categories.group("services").status("live").find() %}
  {% set locations = craft.categories.group("locations").status("live").find() %}
  
  {% set queryKeywords = craft.request.getParam("keywords") | trim %}
  {% set queryServices = craft.request.getParam("services") %}
  {% set queryLocations = craft.request.getParam("locations") %}
  
  <form action="" method="POST">
      <input type="text" name="keywords" value="">
      {% if services | length %}
          {% for service in services %}
          <label>{{ service.title }}<input type="checkbox" name="services[]" value="{{ service.slug }}" /></label>
          {% endfor %}
      {% endif %}
      {% if locations | length %}
          {% for location in locations %}
          <label>{{ location.title }} <input type="checkbox" name="locations[]" value="{{ location.slug }}"/></label>                                     
          {% endfor %}
      {% endif %}
      <button type="submit">Refine</button>
  </form>
  
  {% set originalKeywords = craft.request.getParam("keywords") | trim %}
  {% set keywords = originalKeywords | replace({ "*" : "" }) %}
  {% set services = craft.request.getParam("services") %}
  {% set locations = craft.request.getParam("locations") %}
  
  {% if (keywords | length) or (services | length) or (locations | length) %}
      {% set relatedTo = ["and"] %}
  
      {% set serviceCategoryIds = [] %}
      {% set locationCategoryIds = [] %}
  
      {% set serviceCategories = craft.categories.group("services") %}
      {% set locationCategories = craft.categories.group("locations") %}
  
      {% set servicesCategories = services | join(", ") | trim %}
      {% if services | length %}
          {% for service in services %}
              {% set serviceCategoryIds = serviceCategories.slug(servicesCategories).ids() %}
          {% endfor %}
      {% endif %}
      {% if serviceCategoryIds | length %}
          {% for serviceCategoryId in serviceCategoryIds %}
              {% set relatedTo = relatedTo | merge([serviceCategoryId]) %}
          {% endfor %}
      {% endif %}
  
      {% set locationsCategories = locations | join(", ") | trim %}
      {% if locations | length %}
          {% for location in locations %}
              {% set locationCategoryIds = locationCategories.slug(locationsCategories).ids() %}
          {% endfor %}
      {% endif %}
      {% if locationCategoryIds | length %}
          {% for locationCategoryId in locationCategoryIds %}
              {% set relatedTo = relatedTo | merge([locationCategoryId]) %}
          {% endfor %}
      {% endif %}
  
      {% set keywords = "*" ~ keywords | replace({ " " : "* *" }) ~ "*" %}
  
      {% set allMembers = craft.users.group("members").status("live").search(keywords).order("score") %}
  
      {% if (relatedTo | length) > 1 %}
          {% set allMembers = allMembers.relatedTo(relatedTo) %}
      {% endif %}
  
      <h3>{{ allMembers | length }} Result{% if (allMembers | length) == 1 %}{% else %}s{% endif %}</h3>
  
      {% if allMembers | length %}
          {% paginate allMembers as members %}
  
              <ul>
                  {% for member in members %}
                  <li>{{ member.fullName }}</li>
                  {% endfor %}
              </ul>
  
              {% if paginate.totalPages > 1 %}
              <ul>
                  <li><a href="{{ paginate.firstUrl }}" title="First Page">&laquo;</a></li>
                  {% if paginate.prevUrl %}<li><a href="{{ paginate.prevUrl }}" title="Previous Page">&lsaquo;</a></li>{% endif %}
                  {% for page, url in paginate.getPrevUrls(4) %}
                  <li><a href="{{ url }}" title="Page {{ page }}">{{ page }}</a>
                  {% endfor %}
                  <li class="current"><a href="" title="Page {{ paginate.currentPage }}">{{ paginate.currentPage }}</a></li>
                  {% for page, url in paginate.getNextUrls(4) %}
                  <li><a href="{{ url }}" title="Page {{ page }}">{{ page }}</a>
                  {% endfor %}
                  {% if paginate.nextUrl %}<li><a href="{{ paginate.nextUrl }}" title="Next Page">&rsaquo;</a></li>{% endif %}
                  <li><a href="{{ paginate.lastUrl }}" title="Last Page">&raquo;</a></li>
              </ul>
              {% endif %}
  
          {% endpaginate %}
  
      {% else %}
          <p>Your search didn&#39;t return any members.</p>
      {% endif %}
  
  {% endif %}
  
  ```
  
  **Tags:** pagination
  
  > **Comments:**
  > **username_0**: Marion, the question titled "How to paginate search results?" only uses a query param. My question is related to using a form with multiple fields so the solution in "How to paginate search results?" doesn't work for me.  
  > **username_1**: Hi username_0, can you edit your question and add some of your existing code? That will help us figure out exactly what needs to be changed, and also shed some light as to why this question is not a duplicate.  
  > **username_0**: I've added my existing code. My question is not a duplicate. Is are no other questions posted that has 3 form fields and paginates that search results. All previous posts only have 1 form field and the solutions in those questions don't work for me.  
  > **username_0**: Guys, please read my comments above - the solutions in these other questions do not work for me. Why are you still marking this question as a duplicate! Can you please explain why? All I want is a solution to **my issue**, which are **not** the same as these other questions! These other solutions only use 1 form field, I am using 3 form fields and pagination is not working.  
  > **username_0**: It's very frustrating when everyone jumps on the "duplicate" bandwagon. It's like no one is fully reading my question and comments, realising the difference between mine and this other question (http://craftcms.stackexchange.com/questions/644/how-to-paginate-search-results).  
  > **username_2**: This is clearly not the same problem, please read the question properly before marking as a duplicate.  
  > **username_3**: username_0, what's the URL you are getting on page 2 for `{% paginate entries.limit(9) as paginatedEntries %}` and a link `<a href="{{ paginate.nextUrl }}?{{ craft.request.getQueryStringWithoutPath() }}">&rsaquo;</a>`?  
  > **username_3**: Ahhh... you're sending the form data using `method="POST"`. This can't work with the suggested "solutions". Remove this or change to `method="GET"` as a temporary fix.  
  > **username_4**: @username_0 Don't get too frustrated... everyone is doing what they can on a site like this. It can be challenging to follow the minutia of a question's specific details because we can't see the code and aren't absorbing all the details.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_5 on 2015-01-27. Score: 5 | Accepted answer
  
  To get this working, you will need to find a way to continue passing all of your form’s values to each of the additional pages.
  
  There are a few ways you could do that, but the easiest and best option is to change your search form’s `method` attribute to `"get"` rather than `"post"`.
  
  ```
  <form method="get">
  
  ```
  
  *(Side note: there’s no need to add `action=""` – the default browser behavior if that attribute is omitted is for the form to submit to the current URL.)*
  
  Now when you submit your form you will see all of the form values show up in the resulting page’s query string. While that’s not quite as nice-looking, its advantages outweigh the ugly: browsers won’t ask users if they are sure they want to resubmit a form when they click the Back/Forward buttons, and the URLs will be sharable.
  
  The next step is to update your pagination links to include the query string, which will effectively pass on the form’s values between each of the pages. We’ll use [craft.request.getQueryStringWithoutPath()](http://buildwithcraft.com/docs/templating/craft.request#getQueryStringWithoutPath) for that:
  
  ```
  {% set qs = '?' ~ craft.request.getQueryStringWithoutPath() %}
  
  <li><a href="{{ paginate.firstUrl ~ qs }}" title="First Page">&laquo;</a></li>
  {% if paginate.prevUrl %}
     <li><a href="{{ paginate.prevUrl ~ qs }}" title="Previous Page">&lsaquo;</a></li>
  {% endif %}
  {% for page, url in paginate.getPrevUrls(4) %}
     <li><a href="{{ url ~ qs }}" title="Page {{ page }}">{{ page }}</a>
  {% endfor %}
  <li class="current"><a href="" title="Page {{ paginate.currentPage }}">{{ paginate.currentPage }}</a></li>
  {% for page, url in paginate.getNextUrls(4) %}
     <li><a href="{{ url ~ qs }}" title="Page {{ page }}">{{ page }}</a>
  {% endfor %}
  {% if paginate.nextUrl %}
     <li><a href="{{ paginate.nextUrl ~ qs }}" title="Next Page">&rsaquo;</a></li>
  {% endif %}
  <li><a href="{{ paginate.lastUrl ~ qs }}" title="Last Page">&raquo;</a></li>
  
  ```
  
  
  ---
  
  