#8426 closed defect (fixed)
Form: multiple TextBoxes with the same 'name' attribute are not returned as array
Reported by: | coldfire22x | Owned by: | Douglas Hays |
---|---|---|---|
Priority: | high | Milestone: | 1.4 |
Component: | Dijit - Form | Version: | 1.2.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
When creating multiple TextBox? widgets with the same "name" attribute within the same dijit.form.Form, form.attr("value") does not return all of those values as an array. See attached.
Attachments (2)
Change History (13)
Changed 13 years ago by
Attachment: | TestCase.txt added |
---|
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Owner: | set to bill |
---|---|
Status: | new → assigned |
Hmm, that's odd, it works for checkboxes, see http://download.dojotoolkit.org/release-1.2.1/dojo-release-1.2.1/dijit/tests/form/Form.html.
Must be a problem either with the name ("value[]" rather than just "value"), or with TextBox rather than CheckBox. I'll take a look.
comment:3 Changed 13 years ago by
Milestone: | tbd → 1.4 |
---|---|
Summary: | Multiple TextBoxes with the same 'name' attribute are not returned as array → Form: multiple TextBoxes with the same 'name' attribute are not returned as array |
OK, I looked over the code of Form.js. Currently only checkboxes with the same name are handled. Dates back to [9766].
The issue doesn't have anything to do w/the special characters in the name.
comment:5 Changed 13 years ago by
Owner: | changed from bill to Douglas Hays |
---|---|
Status: | assigned → new |
Doug, I think you were working on this, right?
_setValueAttr() with an array should assign the list of values sequentially, so that the first array element gets assigned to the first TextBox and so forth.
Actually, there's code for that already, not sure why it isn't working:
// otherwise, values is a list of values to be assigned sequentially to each widget dojo.forEach(widgets, function(w, i){ w.attr('value', values[i]); });
comment:6 Changed 13 years ago by
Status: | new → assigned |
---|
Changed 13 years ago by
Attachment: | 8426.patch added |
---|
patch file to create an array for duplicate named widgets
comment:7 Changed 13 years ago by
The patch looks good for Form.getValue()... is setValue() working correctly too? There should be a test for that.
As I said on IM, I think lines 239-242 could be simplified to dojo.setObject(name, [prev, value], obj);
.
The other thing this made me think about was how to handle single checkboxes. I'd like to change the current behavior but I think it needs to wait until 2.0, so I filed #9962.
comment:8 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:9 Changed 13 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
On chrome 3 I'm getting failures (in the Form.html unit test) that the value is reported as duplicate: ["three"]
instead of duplicate: ["first", "second", "third"]
. It's working on FF (although I'm seeing another problem with Editor's value being blank, probably a race condition about the iframe initialization).
comment:10 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:11 Changed 11 years ago by
Component: | Dijit → Dijit - Form |
---|
don't names within a form have to be unique?