gsr
01/08/2023, 3:52 PMAdam Cameron
[] at them. They get posted exactly the same as any other field.
So if you have <select name="city[]"> (etc), then the value will be put into the form scope as city[]. Because city[] contains the [] which can't be used in a dot-notation struct key reference, you'll need to use bracket notation to access them, eg: form["city[]"]Michael Schmidt
01/08/2023, 7:40 PM<cfscript>
function fixFormScope()
{
var tmpParams = getPageContext().getRequest().getParameterMap();
var i = "";
if ( StructIsEmpty(tmpParams) )
fixFormScopeMultiPart();
else
{
cfloop ( collection=tmpParams, item="i")
{
if ( StructKeyExists(FORM, i) )
form[i] = tmpParams[i];
}
}
}
function fixFormScopeMultiPart()
{
var tmpArr = FORM.getPartsArray();
var i = "";
var tmpForm = {};
cfloop ( array=tmpArr, index="i" )
{
if ( i.IsParam() )
{
if ( StructKeyExists(tmpForm, i.getName()) )
{
if ( not IsArray(tmpForm[i.getName()]) )
{
tmpForm[i.getName()] = [tmpForm[i.getName()]];
}
ArrayAppend(tmpForm[i.getName()], i.getStringValue());
} else {
tmpForm[i.getName()] = i.getStringValue();
}
}
}
cfloop ( collection=tmpForm, item="i")
{
form[i] = tmpForm[i];
}
}
</cfscript>gsr
01/09/2023, 3:06 PM