PolymerElements / iron-form

Custom form element
https://www.webcomponents.org/element/PolymerElements/iron-form
63 stars 81 forks source link

[feature request] form elements #272

Open vdegenne opened 6 years ago

vdegenne commented 6 years ago

A native form element provides the elements property which contains a list of all the elements in the form (input, select, ...). However one would expect to use paper-input or other web-components that Polymer provides. elements of a native form element ignores tags that it doesn't know so for instance, this :

<iron-form>
  <form id="myForm">
    <paper-input name="firstname" label="firstname"></paper-input>
    <paper-input name="lastname" label="lastname"></paper-input>
    <input type="hidden" name="id" value="1">
  </form>
</iron-form>

<script>
  console.log(window.myForm.elements); // only contains the native hidden type input (id)
</script>

That'd be great if one could do :

<iron-form id="mySuperForm">
  <form>
    <paper-input name="firstname" label="firstname"></paper-input>
    <paper-input name="lastname" label="lastname"></paper-input>
    <input type="hidden" name="id" value="1">
  </form>
</iron-form>

<script>
  console.log(window.mySuperForm.elements); // returns all the three elements (firstname, lastname, id)
</script>