Opened 12 years ago

Closed 12 years ago

#8212 closed defect (fixed) programmatic usage does not allow multi-valued form fields

Reported by: Jared Jurkiewicz Owned by: Jared Jurkiewicz
Priority: high Milestone: 1.3
Component: IO Version: 1.2.1
Keywords: Cc:
Blocked By: Blocking:

Description programmatic usage does not allow multi-valued form fields

This problem was reported by a co-worker of mine. He was using iframe programmatically and found that by passing content with a property name that had an array of values as its value, it wouldn't properly post them as a multi-valued field. His exact statement was:

We are sending a key args.content.shareWith with a value = ["user1", "user2"]

It makes it to the server with a single value of user1, user2 as opposed to two separate values.

Here is what is sent (seen using fiddler:

Content-Disposition: form-data; name="shareWith"


but we expect:

Content-Disposition: form-data; name="shareWith"


Content-Disposition: form-data; name="shareWith"


The fix for this is a change to one function:

And the fix is to just detect array values and iterate through them, creating multiple inputs:



if we have things in content, we need to add them to

the form

before submission var pHandler = function(name, value) {

var tn; if(dojo.isIE){

tn = dojo.doc.createElement("<input type='hidden'



tn = dojo.doc.createElement("input"); tn.type = "hidden"; = name;

} tn.value = value; fn.appendChild(tn); ioArgs._contentToClean.push(name);

}; for(var x in content){

var val = content[x]; if(dojo.isArray(val) && val.length > 1){

var i; for (i = 0; i < val.length; i++) {







fn[x].value = val;





I've attached a patch for this that will apply to trunk.

If you're okay with the fix, I'll commit it in.

Attachments (1) (1.4 KB) - added by Jared Jurkiewicz 12 years ago.
Patch for iframe multivalued attribute issue.

Download all attachments as: .zip

Change History (5)

Changed 12 years ago by Jared Jurkiewicz

Patch for iframe multivalued attribute issue.

comment:1 Changed 12 years ago by James Burke

On the patch: I guess if it is an array, then it is not likely that a form field with that name already exists, so no need to do the fn[x] check for the array case. At least that is what the patch supposes. That should be OK: it seems unlikely that you would pass an array for a value for a single field in the form.

This change keeps the general contract set up by dojo.formToObject and dojo.objectToQuery in the treatment of arrays to values. Patch sounds like a good idea. Feel free to commit.

comment:2 Changed 12 years ago by Jared Jurkiewicz

Milestone: tbd1.3
Owner: changed from James Burke to Jared Jurkiewicz

Will do. Thanks for the review!

comment:3 Changed 12 years ago by Jared Jurkiewicz

Status: newassigned

comment:4 Changed 12 years ago by Jared Jurkiewicz

Resolution: fixed
Status: assignedclosed

(In [15975]) Fix for multivalued form field. fixes #8212

Note: See TracTickets for help on using tickets.