Created
July 9, 2012 20:03
-
-
Save zvineyard/3078575 to your computer and use it in GitHub Desktop.
CodeIgniter: Add blank value to form_dropdown() and validate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$this->form_validation->set_rules('test', 'Test Field', 'required'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$options = array('' => 'Select One...'); | |
foreach($tests->result() as $test) { | |
$options[$test->id] = $test->name; | |
} | |
echo form_dropdown('test', $options, set_value('test')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
great :)