#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: |
Description
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
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:2 Changed 13 years ago by
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".
Martin
comment:4 Changed 10 years ago by
Component: | Dijit → Dijit - Form |
---|
Looks like it's working to me. Try http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/form/Form.html.
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: