Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#7580 closed defect (worksforme)

Problem with dijit.form.Form.getValues() with dijit.Form.MultiSelect descendant

Reported by: MConlon Owned by:
Priority: high Milestone: 1.2
Component: Dijit - Form Version: 1.1.1
Keywords: dijit.form.Form dijit.form.MultiSelect getValues() getValue() Cc:
Blocked By: Blocking:


This is a form element which can return an array of values and for some reason using dojo.setObject with the array as a parameter adds a lot of cruft to the dijit.form.Form's return object.

As a testcase, check the object returned by getValues() for any dijit.form.Form with a dijit.form.MultiSelect? in it.

Something like this fixes it... may not be the tidest/easiest/etc., but it works. Sub in for the "plain input" clause:

                if (/MultiSelect/.test(widget.declaredClass)) {
                    var ary = dojo.getObject(name, false, obj);
                    if (!ary) {
                        ary = [];
                        dojo.setObject(name, ary, obj);
                    dojo.forEach(value, function(v){ary.push(v)});
                } else {
                    // plain input
                    dojo.setObject(name, value, obj);

A better idea might be to re-write the getValues() code to check if getValue() returned a single value or an array. Although I can't think of many examples of the latter. Probably just MultiSelect?.

Change History (4)

comment:1 Changed 13 years ago by bill

Resolution: worksforme
Status: newclosed

Looks like it's working to me. Try

What output is getValues() giving you, and what output do you expect? Does the problem reproduce with Form.html? If not, you need to attach a test case.

The expected output of getValues() is something like:

  "singleSelect": "VA",
  "multiSelect": [ "VA", "WA" ]

comment:2 Changed 13 years ago by MConlon

That's not what getValues() returns, unless you run it through dojo.toJson() as you can see in Form.html.

It appears this is either a documentation or implementation error, because the docs say "generate JSON structure from form values [sic] get widget values".


comment:3 Changed 13 years ago by bill

Docs have been updated for 1.2, see [13954].

comment:4 Changed 11 years ago by bill

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