select-pure
select-pure copied to clipboard
using inside form creates multiple hidden inputs.
Hi,
I'm using this inside a form. My html is being rendered as
<select-pure class="form-control" id="tags" multiple="true" name="tags[]">
<option-pure value="7">asd</option-pure>
<option-pure value="8">asss</option-pure>
</select-pure>
This generates 5 hidden input fields where only the last one ever gets the select values.
<input type="hidden" name="tags[]">
<input type="hidden" name="tags[]">
<input type="hidden" name="tags[]">
<input type="hidden" name="tags[]">
<input type="hidden" name="tags[]" value="7,8">
If i only render
<select-pure class="form-control" id="tags" multiple="true" name="tags[]">
<option value="7">asd</option-pure>
<option value="8">asss</option-pure>
</select-pure>
The resulting html is only one hidden input field, which is what's expected.
I would suggest having them rendered as hidden, one per option-pure element, but make it "disabled" if its not selected.
By doing it this way, it possible to get the selected options as an array in the backend.
expected => ["8", "7"],
current => ["8,7"],
EDIT: Note that the expected values here, are the ones that are received if using a standard
Thanks for the report!
Multiple renderred hidden inputs should not be happening from 2.1.1-alpha.0 version. Not sure about the second issue yet, will have to think about it.