Skip to content

<sl-select> with "muiltiple" only sends a single item to FormData, when more than one is selected. #1799

Answered by claviska
ourson66 asked this question in Help
Discussion options

You must be logged in to vote

Shoelace is designed to submit form data the same way as native controls. You can verify this behavior by comparing it to a native <select>:

https://codepen.io/claviska/pen/ExMjmgw?editors=1000

Note the query string after submission:

?native=option-1&native=option-2&shoelace=option-1&shoelace=option-2

It's been awhile but, with PHP, I believe you need to append square brackets to the name to tell PHP to parse it as an array, otherwise you'll only get the last selected value.

<sl-select name="rx_colorrestrict[]" ... >

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ourson66
Comment options

Answer selected by ourson66
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
bug Things that aren't working right in the library.
2 participants
Converted from issue

This discussion was converted from issue #1798 on December 28, 2023 14:36.