Welcome Guest, Not a member yet? Register   Sign In
set_value, set_select for form_multiselect in v2
#2

[eluser]zac[/eluser]
According to the user guide, set_select() is intended to be used when you're generating the select HTML by hand, like this:

Code:
<select name="myselect">
<option value="one" &lt;?php echo set_select('myselect', 'one', TRUE); ?&gt; >One</option>
<option value="two" &lt;?php echo set_select('myselect', 'two'); ?&gt; >Two</option>
<option value="three" &lt;?php echo set_select('myselect', 'three'); ?&gt; >Three</option>
</select>

Instead, form_multiselect() wants an array of values as its third parameter. The $_POST array will contain whatever values the user selected:

Code:
&lt;?=form_multiselect('goal_id[]', $goals, $_POST['goal_id[]'])?&gt;

Or if you're using CI's Input class, then something like this:

Code:
&lt;?=form_multiselect('goal_id[]', $goals, $this->input->post('goal_id[]'))?&gt;


Messages In This Thread
set_value, set_select for form_multiselect in v2 - by El Forum - 04-12-2011, 10:02 AM
set_value, set_select for form_multiselect in v2 - by El Forum - 04-12-2011, 12:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB