【发布时间】:2015-12-16 09:52:34
【问题描述】:
我是 codeIgniter 的新手,我刚开始就被卡住了。我正在使用 HMVC 扩展,在验证时出现以下错误:
无法访问与您的字段名称密码对应的错误消息。(pword_check)
任何帮助将不胜感激
代码:
public function submit()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required|max_length[30]|xss_clean');
$this->form_validation->set_rules('pword', 'Password', 'required|max_length[30]|callback_pword_check|xss_clean');
if ($this->form_validation->run() == FALSE)
{
$this->login();
}
else
{
echo 'Success'; die();
}
}
public function pword_check($str)
{
if ($str == 'test')
{
$this->form_validation->set_message('pword_check', 'The %s field can not be the word "test"');
return FALSE;
}
else
{
return TRUE;
}
}
【问题讨论】:
-
你使用哪个 CI 版本???
-
我正在使用 CodeIgniter 版本 3.0.1
标签: php codeigniter validation hmvc