Codeigniter - Form helper set_select() Codeigniter - Form helper set_select() codeigniter codeigniter

Codeigniter - Form helper set_select()


set_select you can use if you produce with html code not with helper.

Although you can do something like this

$selected = ($this->input->post('guide')) ? $this->input->post('guide') : 'investments';                        echo form_dropdown('guide', $guide_options, $selected);


Try this:

echo form_dropdown('guide', $guide_options,set_value('guide', 'investments'));

http://codeigniter.com/forums/viewthread/97665/


You Don't have to Use set_select() as you are already defining selected item in from_dropdown()

form_dropdown('guide', $guide_options, 'investments');

For better understanding refer below code and output

$options = array(                  'small'  => 'Small Shirt',                  'med'    => 'Medium Shirt',                  'large'   => 'Large Shirt',                  'xlarge' => 'Extra Large Shirt',                );$shirts_on_sale = array('small', 'large');echo form_dropdown('shirts', $options, 'large');// Would produce:<select name="shirts"><option value="small">Small Shirt</option><option value="med">Medium Shirt</option><option value="large" selected="selected">Large Shirt</option><option value="xlarge">Extra Large Shirt</option></select>