PolymerElements/paper-radio-group

Name attribute

Akash-dvd opened this issue · 3 comments

The group doesn't have a name field. This field can act as key while the button as the value.
Currently coz of its absence form serialize() spits out button name with on/off tag.
Its much consistent in terms of design than the extra field to specify the selection.

paper-radio-groups are only used to group the buttons, and have no effect on form serialization. The name and value attributes should be put on each paper-radio-button individually, not the radio group. Secondly, a radio-button without a value attribute set will have a default value of "on". This is exactly now the native HTML radio buttons work:

Submitting this form:

<form>
  <input type="radio" name="foo"checked>input1 
  <input type="radio" name="foo">input2
  <input type="submit" value="Submit">
</form>

Will serialize to foo=on. However, if you give the buttons proper values:

<form>
  <input type="radio" name="foo" value="first" >input1 
  <input type="radio" name="foo" value="second" >input2
  <input type="submit" value="Submit">
</form>

Will serialize to foo=first.

So in your form, you can use a paper-radio-group, but you need to set a value on the paper-radio-button

Hope this helps!

Ok , thanks for the elaboration.
But still i believe paper-radio-groups element should have a name. Its value can be the selected paper-radio-button name.
Its also better to have named groups.
For example a form has many single choice questions.
Every question can be represented by paper-radio-groups name and the answer by the name of the selected button.
Besides the value of button is binary. Only name is sufficient to imply the selection.
It will be relatively tough to implement the above example with current design.
While the given example is pretty generic.

If you have many single choice questions, this is indicated by the name attribute of the radio-buttons in the group, not the paper-radio-group itself (see http://www.w3.org/TR/html-markup/input.radio.html#input.radio.attrs.name)

I'm closing this, since this isn't how the native element works, and I think it will add a lot of confusion: For example, in this code:

<form>
  <paper-radio-group name="group">
    <paper-radio-button name="foo" value="zig" checked></paper-radio-button>
    <paper-radio-button name="foo" value="zag"></paper-radio-button>
  </paper-radio-group> 
</form>

The form, according to this enhancement, would submit group=zig&foo=zig. The selected paper-radio-button is already given by the foo name, and now it's being duplicated, which I think is bad and slightly confusing (especially since people are already expecting paper-radio-group to do the right thing).

Closing this for now.