自定义错误消息不显示错误,它只显示空白页而是错误消息
这是我的控制器:
public function daftar(){
$this->form_validation->set_rules('email','Email','required');
$this->form_validation->set_rules('nama','Nama','required');
$this->form_validation->set_rules('pass','Password','required');
$this->form_validation->set_rules('passconf','PasswordConf','required|matches[pass]');
if($this->form_validation->run()==FALSE){
$this->form_validation->set_message('passconf','the password doesnt match');
}
else{
redirect('lowongan/daftar_employer');
}
}
}
答案 0 :(得分:0)
你需要在“不”中删除撇号。
$this->form_validation->set_message('passconf','the password doesn\'t match');
答案 1 :(得分:0)
编写自定义回调函数来设置自己的错误消息
callback_custom_error
$this->form_validation->set_rules('passconf','PasswordConf','required|matches[pass]|callback_custom_error');
public function custom_error($str)
{
if($this->form_validation->run()==FALSE)
{
$this->form_validation->set_message('passconf','your custom message');
return FALSE;
}
else
{
return TRUE;
}
}