form_dropdown repopulate |
[eluser]JanDoToDo[/eluser]
Hey guys, Im wondering how to reselect a submitted dropdown item if the form validation fails using the form helper. Obviously it can't be done the standard way with set value as the html isnt written - its done using the form helper?
[eluser]must[/eluser]
there is set_select() available in the form helper check it out in the user guide Example: Code: <select name="myselect"> check http://ellislab.com/codeigniter/user-gui...elper.html it can also be done by set_value() but it's pretty much the same principal Code: <select name="some_select"> And there are a lot of other ways to exploit this
[eluser]JanDoToDo[/eluser]
But I can't do that If i make a dropdown with the form helper, i.e form_dropdown('select_options', $options, $selected);
[eluser]must[/eluser]
i never use form helper to help me generate html input ... but looking into the documentation i see that you can set a value to be selected in the third parameter. it can contain the value that you want to be selected by doing something like : Code: $values = array(....); and if you look to the form_helper.php you can notice that this would be done automatically if you do not set a select value (the third parameter) |
Welcome Guest, Not a member yet? Register Sign In |