id summary reporter owner description type status priority milestone component version resolution keywords cc blockedby blocking
8212 dojo.io.iframe programmatic usage does not allow multi-valued form fields Jared Jurkiewicz Jared Jurkiewicz "dojo.io.iframe 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:
-----------------------------11323553721538
Content-Disposition: form-data; name=""shareWith""
user1,user2
but we expect:
-----------------------------165122398613290
Content-Disposition: form-data; name=""shareWith""
user1
-----------------------------165122398613290
Content-Disposition: form-data; name=""shareWith""
user2
The fix for this is a change to one function:
dojo.io.iframe._fireNextRequest
And the fix is to just detect array values and iterate through them, creating multiple inputs:
if(fn){
if(content){
// 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("""");
}else{
tn = dojo.doc.createElement(""input"");
tn.type = ""hidden"";
tn.name = 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++) {
pHandler(x,val[i]);
}
}else{
if(!fn[x]){
pHandler(x,val);
}else{
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.
" defect closed high 1.3 IO 1.2.1 fixed