Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

using inside form creates multiple hidden inputs. #40

Open
antondalgren opened this issue Jun 16, 2021 · 3 comments
Open

using inside form creates multiple hidden inputs. #40

antondalgren opened this issue Jun 16, 2021 · 3 comments

Comments

@antondalgren
Copy link

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">
@antondalgren
Copy link
Author

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.

@antondalgren
Copy link
Author

antondalgren commented Jun 16, 2021

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 and tags with multiple values selected.

@dudyn5ky1
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants