CodeIgniter Forums

Full Version: how does form_dropdown() magically repopulate my dropdown ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum


I am an almost complete CI newbie (but completely loves the framework anyway!)

I don't understand how my dropdown is (magically) repopulated on submit (by post value) as I don't provide any default value or set_value rule.

Here is my code :

view :
echo form_dropdown('marque', $options_marque, $options_marque_selected);

controller :
$data['options_marque'] = $this->load->model('global/marque_model')->get_options();
$data['options_marque_selected'] = array();

If I run form_validation on submit with an error, my dropdown is repopulated with the value I chose even if I don't provide any set_value or set_select instruction !

Where is the magic ?