繁体   English   中英

CodeIgniter自定义错误消息不起作用?

[英]CodeIgniter custom error messages not working?

我已经阅读了文档,但是此表单仍显示默认消息吗?

据我了解,我正在设置规则,然后将一条消息应用于该规则?

https://www.codeigniter.com/user_guide/libraries/form_validation.html

$this->load->library('form_validation');
    $this->form_validation->set_error_delimiters('<p class="text-danger"><i class="fa fa-exclamation-triangle"></i> ', '</p>'); //Controls what element the error is put in, <p> by default.//
    $this->form_validation->set_rules('Username', 'Username', 'trim|required');
    $this->form_validation->set_message('Username', 'username required');
    $this->form_validation->set_rules('Password', 'Password', 'trim|required|callback_CheckDatabase');
    $this->form_validation->set_message('Password', 'password required');

如果您需要根据某些特定规则为特定字段设置自定义错误消息,请使用set_rules()方法:

$this->form_validation->set_rules('field_name', 'Field Label', 'rule1|rule2|rule3',
    array('rule2' => 'Error Message on rule2 for this field_name')
);

您正在使用旧文档。 文件资料

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM