I am trying to submit a form using CFHTTP to a PHP page - everything is working properly except for one form field that is using arrays.
The HTML code in the form is
<select name="groupselect[]" id ="groupselect" size="10" multiple="multiple">
<option value="26713">X-Men</option>
</select>
When I submit using CFHTTP all of the other form fields are submitted and recognised, but not this one.
I have tried
<cfhttpparam type="formfield" name="groupSelect[]" value='26713'>
<cfhttpparam type="formfield" name="groupSelect" value='26713'>
<cfhttpparam type="formfield" name="groupSelect[0]" value='26713'>
<cfhttpparam type="formfield" name="groupSelect[]" value='Array ( [0] => 26713 )'>
<cfhttpparam type="formfield" name="groupSelect" value='Array ( [0] => 126713 )'>
I have tried serialising, I have tried WDDX, I have tried everything I can think of and have had no luck. What am I overlooking? At the moment I only need to submit one value using this field, but in the future I may need to submit multiple values.
Any help would be greatly appreciated.
EDIT AFTER FIRST COMMENT
I did some more debugging and now I am more puzzled! When I submit the form manually $_Post returns:
Array
(
[groupselect] => Array
(
[0] => 26713
)
)
Then I submitted the form using cfhttpparam type="formfield" name="groupSelect[]" value='26713' and the $_Post returned the exact same response! When I take the square brackets out, it shows me just a variable, not an array...
So, if that is working I guess I need to test some more with the live site and see why it isnt working?
OK - it turns out that the way to do this in ColdFusion is the most obvious way:
However, for the ColdFusion programmers out there, PHP is case sensitive when it comes to variable names...
So while my name="groupSelect[]" wasnt working, name="groupselect[]" works perfectly!
Hakre, thanks for pointing me in the right direction with the suggestion of debug, and hopefully this helps someone else in the future!