0

自定义错误消息不显示错误,它只显示空白页而不是错误消息

这是我的控制器:

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');
 }

 }

}

4

2 回答 2

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;
    }

}
于 2013-08-24T08:16:33.370 回答
0

您需要避开“不”一词中的撇号。

$this->form_validation->set_message('passconf','the password doesn\'t match');
于 2013-08-24T01:47:27.953 回答