Opened 10 years ago
Closed 10 years ago
#9420 closed defect (fixed)
dojo.formToObject radio button: value is array or string depending on the selection
Reported by: | Juho Manninen | Owned by: | anonymous |
---|---|---|---|
Priority: | high | Milestone: | 1.4 |
Component: | General | Version: | 1.3.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
dojo.formToObject returns an object where value for a radio button group can be either an array or a string. This depends on whether the last or any other button is checked.
If we have a group of 4 radio buttons and we select the last one, we get "4". Selecting the second last leads to ["4",null] and selecting the first to ["4",null,null,null]. See file attached demonstrating this.
From my point of view this should always return string.
Affects at least versions from 1.2 to 1.3.1. Not connected to dojo.fieldToObject.
Attachments (3)
Change History (7)
Changed 10 years ago by
Attachment: | test_dojoFormToObject.html added |
---|
Changed 10 years ago by
Attachment: | formToObject.diff added |
---|
Proposed fix filters out null values [CLA]
comment:1 Changed 10 years ago by
The attached diff fixes the problem for radio button and checkbox groups. It doesn't break the current checkbox behavior: If a checkbox group has several selected it results to an array. Textboxes are not affected as the value is an empty string, not a null value.
CLA Manninen.
Changed 10 years ago by
Attachment: | formToObjectRadioGroupTests.diff added |
---|
Extended xhr tests to verify the patch
comment:2 Changed 10 years ago by
comment:3 Changed 10 years ago by
IIUC, I dealt with the same issue in dijit.form.Form.
You might want to also check (no pun intended) that checkboxes (multiple checkboxes w/the same name) work correctly. Do they always return an array, even when exactly one checkbox is checked?
comment:4 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Simple form with radio buttons demonstrates the bug