我想将自定义常规样式应用于set_rules
表单验证类的CodeIgniter方法中的所有“人名” :
$this->form_validation->set_rules(<name of field>, <human name>, <rules>);
假设我想用黑体字标出所有“人名”,我知道我可以这样做:
$this->form_validation->set_rules(<name of field>, <strong>human name</strong>, <rules>);
但是,一旦要样式化的字段数量变多,这将很难管理。
有没有办法使用类似的东西来访问它set_error_delimeters
?
$this->form_validation->set_error_delimeters('<div class="error">', '</div>');
其中我可以在set_rules
方法中为此“人名”或第二个参数设置分度?
当前,文档中尚无(至少明确讨论过)的方法。
您要更改人名的错误分隔符吗?
您要在扩展form_validation
类中进行此更改,这样就不必在所有验证类中再次声明它了吗?
如果两者都可以,克里斯将为您提供出色的解决方案!
class MY_Form_validation extends CI_Form_validation {
public function __construct()
{
parent::__construct();
$this->_error_prefix = '<p class="error">';
$this->_error_suffix = '</p>';
}
}
这不必使用protected $CI
魔术,所以我们在这里很好。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句