-
Describe the bugI'm using an with multiple values, this is how it's defined: <sl-select name="rx_colorrestrict" label="Color Restriction:" value="rx_pattern" multiple clearable>
<sl-option value="rx_pattern">No Patterns</sl-option>
<sl-option value="rx_metallic">No Metallics</sl-option>
</sl-select> If there are multiple values selected, as it says in the documentation, I pass a space-delimited string of values in the "value" attribute, which works. The documentation is slightly confusing about the difference between the single space-delimited string used to set the value attribute, vs. the value property, which it says will return an array, "if accessed via javascript" ... (shrug) ... well on the server I actually need it to be a space-delimited string when it arrives in the POST request to the server, and I'm not doing any javascript with the To ReproduceSteps to reproduce the behavior:
As you can see, there's only 1 item showing, where there should be two, because both of the items in the sl-select were showing on the screen as being selected. Browser / OS
Additional informationProvide any additional information about the bug here. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If, before I submit the form, look at the sl-select's value in the DevTools window, console.log(mySelect.value);, I do see a two-item array containing both items [ "rx_pattern", "rx_metallic"]. Interestingly, it's the LAST one which gets sent via the form to the server. |
Beta Was this translation helpful? Give feedback.
-
Shoelace is designed to submit form data the same way as native controls. You can verify this behavior by comparing it to a native https://codepen.io/claviska/pen/ExMjmgw?editors=1000 Note the query string after submission:
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[]" ... > |
Beta Was this translation helpful? Give feedback.
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:
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.