我的代碼如下:笨form_validation回調函數問題
class Test_model extends MY_Model
{
public $validation_rules = [
'field' => 'input_text',
'label' => 'Your Text',
'rules' => 'trim|callback_checkString',
'errors' => [
'checkString' => 'Invalid String',
]
];
public function checkString($x){
return $x==='valid';
}
/* callback function */
public function do_my_job(){
/*form_validation is already loaded in autoload.php*/
$this->form_validation->set_rules($this->validation_rules);
if($this->form_validation->run()){
/*do something*/
}else show_404();
}
}
當我打電話$這個 - > Test_model-> do_my_job()所有其他的驗證工作,但回調函數不是作品.... 它總是拋出我的自定義錯誤「無效的字符串」 !!! ...
任何解決辦法嗎?...
https://codeigniter.com/userguide3/libraries/form_validation.html#setting-error-messages – Narf