form_dropdown() with set_select() |
[eluser]Unknown[/eluser]
I read this topic regarding using form_dropdown() with set_select(), but it doesn't seem to be working for me. I am doing a simple Month-DD-YYYY dropdown combination to accept a person's age. Code: //set month array so, setting dropdowns: Code: <p>Enter your date of Birth:</p> now for the validation set_select(), from the docs in the User's Guide, I must have access to the <OPTION> tags. I don't see how to get to those while using the form helper functions. It seems to me that I must choose one or the other. Certainly there's a way to smoothly use these in conjunction?
[eluser]beyondwords[/eluser]
The best thing I found for this was simply to use the validation data like any other input. ex. Code: <?= form_dropdown('field_id', $field_values, $this->validation->field_id); ?>
[eluser]Unknown[/eluser]
Thanks beyondwords. This was a simple solution, I guess I was making it harder than it was!
[eluser]Phunky[/eluser]
Thats all well and good, but what if you wish to default to a certain option before the form is submitted? EDIT Ignore me im dumb and lazy, i was thinking it would auto do it when instead we should of course do it like so Code: form_dropdown('dropDown', $array,($this->input->post('formElement') ? $this->input->post('formElement') : $defaultValue))
|
Welcome Guest, Not a member yet? Register Sign In |