GET request with multivalued param loses values
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
Description
GET multi valued parameter handling does not conform to web standards (and loses information). When a form contains a multi valued field (e.g. a bunch of checkboxes), the resulting GET request does not yield the expected results. Instead of getting an array of values when multiple values are selected, craft only retains the last value. Craft should at least follow simple HTML form standards?
Steps to reproduce
- create a simple form which submits to the same page and has a form multifield:
<form class="search__facets" action="{{ craft.app.request.absoluteUrl }}">
<input class="c-ccb__input" name="color" value="blue" type="checkbox">
<input class="c-ccb__input" name="color" value="white" type="checkbox">
<input class="c-ccb__input" name="color" value="red" type="checkbox">
<button class="btn btn--submit" type="submit">submit</button>
</form>
- Dump the output of the query param in the template
{{ dump(craft.app.request.getQueryParam('color')) }} - submit the form with multiple checkboxes selected OR call via url: ?color=blue&color=white
instead of getting an array of values when multiple values are selected, craft only retains the last value.
Additional info
- Craft version:
- PHP version: 7.0.15
- Database driver & version: MySQL 5.6.35
- Plugins & versions: No external plugins
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the supplied HTML form or the URL ?color=blue&color=white, then trace Craft's GET query-parameter handling. The issue names no source file or test; done means repeated values are preserved as an array instead of only the final value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100