CodeIgniter Forums
how does form_dropdown() magically repopulate my dropdown ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how does form_dropdown() magically repopulate my dropdown ? (/showthread.php?tid=45243)



how does form_dropdown() magically repopulate my dropdown ? - El Forum - 09-14-2011

[eluser]Unknown[/eluser]
hello

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 :
Code:
echo form_dropdown('marque', $options_marque, $options_marque_selected);

controller :
Code:
$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 ?