Q:

post form multidimensional array in coldfusion

I am trying to post the following :
<input name="answer[1][]" value="Answer 1 question 1"/>
<input name="answer[1][]" value="Answer 2 question 1"/>
<input name="answer[2][]" value="Answer 1 question 2"/>
<input name="answer[2][]" value="Answer 2 question 2"/>
Unfortunately I receive a coldfusion error when posting:
Expression-Element ANSWER is undefined in a Java object of type class [Ljava.lang.String;.
Anyone has an idea on how to solve this problem?

A:

You can't just call a form field "answers[1][]" and hope that some how ColdFusion will work out that string - because that's all "answers[1][]" is: a string - is supposed to be interpreted as  an array reference.  CF doesn't work like that.
Even if it did work like that, you'd need to put a value in the second dimension of the array notation: answers[1][] is not valid CFML.
The first troubleshooting step when variables are appearing to be different to what you expect is to dump the variable out (or in this case, the form scope out):
<cfdump var="#form#">

This would quickly reveal that you don't have an array, you have a two variables in the form scope: one called answer[1][] and the other answer[2][] (where each variable is literally called that).  Dot-notation rules in CF won't allow this to be referenced as form.answer[1][], you need to reference it as form["answer[1][]"].
As of ColdFusion 10, one can have form variables with the same name being set in the form scope as an array, by setting this in your Application.cfc:
 this.sameformfieldsasarray = true

However that obviously (?) only works for a single dimension array.
If you want a multi-dimension array, you'll have to DIY with a loop over the form scope and a variable-name check to see which array / dimension each value should go in.

