Opened 12 years ago

Closed 11 years ago

Last modified 9 years ago

#6420 closed defect (fixed)

Form: getValues() ignores radio sets with no radio selected

Reported by: awhite@… Owned by: Douglas Hays
Priority: low Milestone: 1.3
Component: Dijit - Form Version: 1.1.0
Keywords: getValues() Form Radio dijit.form.Radio dijit.form.Form Cc: bill
Blocked By: Blocking:

Description

If a dijit.form.Form contains a set of radios but none are selected getValues() does not list the radio set. getValues() should have an entry with the name of the radio set and a value of false or null.

On a related note, make sure setValues() with a radio value of null/false unselects all the radios.

Change History (10)

comment:1 Changed 12 years ago by bill

Cc: awhite@… removed
Milestone: 1.1.11.3
Owner: set to bill
Reporter: changed from guest to awhite@…
Summary: dijit.form.Form.getValues() ignores radio sets with no radio selectedForm: getValues() ignores radio sets with no radio selected

Yup, this sounds like a bug.

comment:2 Changed 11 years ago by Douglas Hays

Owner: changed from bill to Douglas Hays
Status: newassigned

comment:3 Changed 11 years ago by MConlon

This is correct behaviour for a set of radio buttons. Not a bug... try it with a regular (not Dojo) form; nothing is reported for a radio button set unless a value is selected. On the other hand, one of the values is always supposed to be selected, and it's the responsibility of the person writing the page. See http://www.w3.org/TR/html401/interact/forms.html.

Perhaps the Dijit RadioButton? logic should ensure the first button is checked if not specified in the page? That's the proper behaviour.

comment:4 Changed 11 years ago by bill

This ticket isn't about the behavior of radio buttons, it's about the behavior of the Form widget (dijit.Form), and it's not about what gets submitted with a <form>, it's about the return value of dijit.form.form.getValues(). getValues() should return an empty array, as per the spec of the dijit.form.Form widget. Admittedly that's an arbitrary choice.

As per the HTML spec listed above, http://www.w3.org/TR/html401/interact/forms.html#h-17.6.1, it says that "Zero or more choices may be pre-selected for the user.", so it doesn't necessarily need to be selected.

comment:5 Changed 11 years ago by MConlon

Radio button is not an "option" (i.e., child of "select"), it's an "input" of type "radio". Section 17.6 does not apply to radio buttons, Section 17.2 does. Radio button groups are supposed to have one radio button selected at all times. They're not optional; that's what "select" is for, where (as you noted) you are allowed a "null" option.

That's why the spec says "since some browsers are broken, make sure you select a default manually."

comment:6 Changed 11 years ago by bill

Oops, yah I misread that. Actually I got confused and thought this ticket was about a group of checkboxes, all unchecked.

Well, I'm not quite ready to punt and make developers indicate an initially selected radio, but maybe I'll change my mind. Will think about it after 1.2.

comment:7 Changed 11 years ago by Douglas Hays

Cc: bill added

bill, I need to know if you want the RadioButton? widget to always force 1 to be checked, or if you want the Form widget to use null for an all-unselected radio group.

comment:8 Changed 11 years ago by bill

OK, please use a null for an all-unselected radio group. As you said on chat that will make setValues(getValues()) work correctly.

comment:9 Changed 11 years ago by Douglas Hays

Resolution: fixed
Status: assignedclosed

[15620] Fixes #6420. getValues() returns null for a radio group with none checked so that setValues() works correctly.

comment:10 Changed 9 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.