表单验证类我把代码
public function custom($str)
{
if ( ! is_array($str))
{
return (trim($str) == '')? FALSE : TRUE;
}
else
{
return ( ! empty($str));
}
}
在表格验证土地上,我把:
$lang['custom'] = "É necessário aceitar os %s";
控制器类代码
$this->form_validation->set_rules('termos','TERMOS E CONDIÇÕES','custom');
它不起作用,我该如何解决这个问题?
答案 0 :(得分:1)
根据Codeigniter documentation,当您想要自定义函数作为验证规则时,您必须在其前面添加callback_
,因此您的规则将如下所示:
$this->form_validation->set_rules('termos','TERMOS E CONDIÇÕES','callback_custom');