Opened 12 years ago

Closed 11 years ago

#2416 closed defect (invalid)

dojo.widget.Form.getValues() ignore fields with names contains "["

Reported by: ziv@… Owned by: Nathan Toone
Priority: high Milestone: tbd
Component: Dijit Version: 0.4.2
Keywords: widget, form, getValues Cc: ziv@…
Blocked By: Blocking:

Description (last modified by dylan)

when using form elements in this form (array of the same input element):

<input type="text" name="field[0]" id="field[0]" />
<input type="text" name="field[1]" id="field[1]" />
<input type="text" name="field[2]" id="field[2]" />
...

the dojo.widget.Form.getValues() function ignore those form elements.

my patch to fix that problem:

--- Form.js            2007-01-10 15:53:52.000000000 +0200
+++ FormPatched.js     2007-02-06 13:51:41.000000000 +0200
@@ -287,10 +287,12 @@

                                if ((elm.type != "select-multiple" && elm.type != "checkbox" && elm.type != "radio") || (elm.type=="radio" && elm.checked)) {
                                        if(name == name.split("[")[0]) {
-                                               myObj[name]=elm.value;
-                                       } else {
-                                               // can not set value when there is no name
-                                       }
+                                                       myObj[name]=elm.value;
+                                               } else if (name != 'undefined' && name != '') {
+                                                       myObj[name] = elm.value;
+                                               } else {
+                                                       // can not set value when there is no name
+                                               }
                                } else if (elm.type == "checkbox" && elm.checked) {
                                        if(typeof(myObj[name]) == 'undefined') {
                                                myObj[name]=[ ];

Attachments (1)

patch-form.patch.txt (15.5 KB) - added by joose 12 years ago.
Patch to Form ("array"-bugfix, validation fixes, coding convention fixes)

Download all attachments as: .zip

Change History (9)

comment:1 Changed 12 years ago by alex

Milestone: 0.4.20.9

comment:2 Changed 12 years ago by alex

ziv,

have you filed a CLA? (http://dojotoolkit.org/icla.txt) or has your company filed a CCLA?

Regards

comment:3 Changed 12 years ago by bill

Component: WidgetsDojox
Milestone: 0.9
Owner: changed from bill to joose

Changed 12 years ago by joose

Attachment: patch-form.patch.txt added

Patch to Form ("array"-bugfix, validation fixes, coding convention fixes)

comment:4 Changed 12 years ago by joose

I don't think that suggested solution will work, because it doesn't do anything for setValues thingie. And I think the solution suggested will not work =)

Anyway, patch included which fixes this text-array thingie. Patch also adds more support for Validation widgets and fixes some coding conventions.

comment:5 Changed 11 years ago by dylan

Milestone: 1.2
Summary: dojo.widget.Form.getValues() ignore fields with names contaisn "["dojo.widget.Form.getValues() ignore fields with names contains "["

Test in 1.2 timeframe, see if the issue remains. If so, let's get it fixed.

comment:6 Changed 11 years ago by bill

Component: DojoxDijit

comment:7 Changed 11 years ago by dylan

Description: modified (diff)
Owner: changed from joose to Nathan Toone

comment:8 Changed 11 years ago by Nathan Toone

Milestone: 1.2tbd
Resolution: invalid
Status: newclosed

I don't know if this is an issue or not.

The documentation of dijit.form.Form.getValues states that it only works on widget form elements. So I don't think that the original issue remains.

Closing for now - if desired, a separate issue could be logged to support getValues for non-widget input elements (though in looking at the code, it appears that at one time it existed, and was removed for some reason...I don't know what that reason would have been.)

Note: See TracTickets for help on using tickets.