I have in form multiselect options list. The Form handles itself. I need, after then I press submit, the multiselect list is been already had with the selected options.
Chunk form:
<form method="post" action="[[~[[+id]]]]" >
Product types:
<select size="7" multiple="multiple" name="prod_type[]">
<option value="1" [[+prod_type:eq=`1`:then=`selected="selected"`:else=``]]>First</option>
<option value="2" [[+prod_type:eq=`2`:then=`selected="selected"`:else=``]]>Second</option>
<option value="3" [[+prod_type:eq=`3`:then=`selected="selected"`:else=``]]>Third</option>
<option value="4" [[+prod_type:eq=`4`:then=`selected="selected"`:else=``]]>Fourth</option>
<option value="5" [[+prod_type:eq=`5`:then=`selected="selected"`:else=``]]>Fifth</option>
<option value="6" [[+prod_type:eq=`6`:then=`selected="selected"`:else=``]]>Sixth</option>
<option value="7" [[+prod_type:eq=`7`:then=`selected="selected"`:else=``]]>Seventh</option>
</select>
<input type=submit value=submit />
</form>
On snippet I tried to return selected options
$FormOutput = $modx->getChunk($formTpl, array(
'prod_type' => $_REQUEST['prod_type']
));
In a result I have array. But nothing is selected.
var_dump("$prod_type")
---
array(3) {
[0] => int(1)
[1] => int(2)
[2] => int(3) }
If I remove "[ ]" (name="prod_type") then i get ONE selected(last selected on form).
How I can return all selected options?
[ed. note: alex_dutch last edited this post 12 years ago.]