carbon-design-system / carbon-for-ibm-dotcom

Carbon for IBM.com is based on the Carbon Design System for IBM
https://www.ibm.com/standards/carbon/
Apache License 2.0
269 stars 156 forks source link

Multi-select bad value: Multi-select does not send an array to backend #9751

Open lyyka opened 2 years ago

lyyka commented 2 years ago

Description

What I expected: When defining bx-multi-select with name="values[]" I expect the input field to submit an array of values that were selected, like [1, 2, 3, ...].

What happened instead: bx-multi-select submits a string of concatenated values like "1,2,3,...". This is really bad, as you cannot natively validate each selected item, and you have to manually extract the array values. Setting the name of the input to values[] or values does not change anything. Setting it as values[] will just send an array with 1 element, and that one element is the above mentioned string.

Component(s) impacted

bx-multi-select

<bx-multi-select name="values[]">
    @foreach($values as $value)
        <bx-multi-select-item value='{{ $value}}'>{{ $value }}</bx-multi-select-item>
    @endforeach
</bx-multi-select>

Browser

Chrome

Carbon Web Components version

latest

Severity

Severity 2 = Aspects of design is broken, and impedes users in a significant way, but there is a way to complete their tasks. Affects major functionality, has a workaround.

Application/website

Laravel application

CodeSandbox example

?

Steps to reproduce the issue (if applicable)

No response

Release date (if applicable)

No response

Code of Conduct

stale[bot] commented 1 year ago

We've marked this issue as stale because there hasn't been any activity for 60 days. If there's no further activity on this issue in the next three days then we'll close it. You can keep the conversation going with just a short comment. Thanks for your contributions.