我在为每个规则的表单验证设置自定义错误消息时遇到问题。
我已经从这里的篝火文档中尝试过
这是我的模块模型的一些代码
class Content_management_system_model extends BF_Model {
protected $table_name = 'article';
protected $key = 'id';
// be updating a portion of the data.
protected $validation_rules = array(
array(
'field' => 'article_alias',
'label' => 'lang:content_management_system_article_alias',
'rules' => 'unique[article.article_alias,article.id]',
'errors' => array(
'unique' => 'This is my custom error',
),
),
在这里,规则是在插入时从管理控制器设置的
private function save_content_management_system($type = 'insert', $id = 0) {
// Validate the data
$this->form_validation->set_rules($this->content_management_system_model->get_validation_rules());
if ($this->form_validation->run() === false) {
return false;
}
但它总是显示默认消息The value in "Article Alias" is already being used.
根据提到的链接中的文档,它应该显示错误This is my custom error