Validating form dropdown in CodeIgniter
- by Gaz
Hi,
I am using CodeIgniter's form helper and form validation library to build my forms. I'm having trouble making the dropdown 'sticky' and also finding appropriate validation rules.
This is how I'm populating the drodown:
foreach($events as $event){
$options[$event->event_title] = $event->event_title;
}
$firstItem = '<option>Please select one...</option>';
echo form_dropdown('events', $options, '', $firstItem);
This is building the options from events stored in the database. The form looks fine and is populating tall the fields correctly.
Hwoever, when I come to submit the form, the dropdown isn't holding onto the value selected? Also, how should I validate it, I want to make it required but I also want to make sure that I dont except the first option in the dropdown 'Please select one...'
Thanks in advance.
Cheers,
Gaz