ビュー、コントローラー、モデルに書き込む必要があるものを codeigniter でドロップダウンの検証がどのように機能するかを知る必要があります。
以下は私のコードですが、動作していません。
view.php
$options = array(
'0' => 'Select',
'1' => 'Dr.',
'2' => 'Mr.',
'3' => 'Mrs.',
'4' => 'Ms.',
'5' => 'Prof.',
'6' => 'Mr. & Mrs.',
);
<?php echo form_dropdown('Title', $options, set_value('title')); ?>
controller.php
$this->form_validation->set_rules('title','Titles','required|callback_select_validate');
function select_validate() {
$gender = $this->input->post('gender');
if($gender == 0) {
return true;
}
else {
$this->form_validation->set_message('check_sex', 'invalid choice');
return FALSE;
}