Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter - Form helper set_select()

How can I use set_select() (part of the form helper) on my dropdown array in codeigniter:

It is used to remember which option the user has selected.

$guide_options = array('investments' => 'Investments',
                       'wills' => 'Wills',
                       'tax-planning' => 'Tax planning',
                       'life-insurance' => 'Life insurance',
                       'currency-exchange' => 'Currency exchange',
                       'retirement-planning' => 'Retirement planning',
                       'international-healthcare' => 'International healthcare',
                       'savings-plans' => 'Savings plans',
                       'education-planning' => 'Education planning',
                       'sipps' => 'SIPPS',
                       'qrops' => 'QROPS',
                       'qnups' => 'QNUPS',
                       'mortgages' => 'Mortgages',
                       'other' => 'Other service'                       
                      );
echo form_dropdown('guide', $guide_options, 'investments');

Form helper guide here: http://codeigniter.com/user_guide/helpers/form_helper.html

like image 939
hairynuggets Avatar asked Dec 03 '22 06:12

hairynuggets


1 Answers

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);
like image 187
Kokers Avatar answered Dec 05 '22 19:12

Kokers