In my form I have an element with square bracket:
<input name="bodyIDList[]" id="bodyIDList" value="">
When I pass this page to ColdFusion how is this treated as a form variable? As a list or an array?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not sure why you are asking this question – it takes literally a few seconds to create a test and find out for yourself!
The code to test it is this simple:
Run that, press go, look at the dump.
But, since we’ve now got this question here, I might as well give a full answer, since there is actually an interesting thing to be aware of…
If you run that code on Adobe ColdFusion 9 (or any other version of CF) you will get a string variable named
bodyIDList[]– that isForm['bodyIDList[]']– with a single value.If you had multiple of these fields you will still get a string with a comma-delimited list.
Since it contains brackets in the variable name, it is not possible to access this field with dot-notation.
All the above also applies for the latest Open BlueDragon.
However, if you use Railo, you will get a different behaviour (copied from PHP) which instead will give you a variable called
bodyIDList– i.e. Form[‘bodyIDList’] with no brackets – which contains an arrayIf you had multiple of these fields you would get a single array with multiple elements.
There is currently no admin configuration option to make Railo compatible with ACF on this, so:
If you are writing cross-engine CFML code, do not use form field names with brackets.
(well, unless you’re aware and willing to deal with the differences).