CodeIgniter是否能够解释
config/form_validation.php
以显示适当的错误消息?
使用控制器时有一种验证方法:$this->form_validation->set_message('min_length', '{field} must have at least {param} characters.');
当前的验证规则(如果有一种方法可以将验证消息添加到与规则相同的数组中,那么最后一个数组就是我感兴趣的。(:
'users' => array(
array(
'field' => 'first_name',
'label' => 'First Name',
'rules' => 'trim|required'
),
array(
'field' => 'last_name',
'label' => 'Last Name',
'rules' => 'trim|required'
),
array(
'field' => 'email_address',
'label' => 'Email Address',
'rules' => 'trim|required|valid_email'
, 'messages'=> array('valid_email'=>'Please make sure your email is correct.')))
你可以阅读并遵循下面链接中的给定示例。我认为这会对你有所帮助。
自定义错误消息-表单验证码点火器
CodeIgniter允许添加文档中描述的验证消息。阵列如下:
'users' => array(
array(
'field' => 'first_name',
'label' => 'First Name',
'rules' => 'trim|required'
),
array(
'field' => 'last_name',
'label' => 'Last Name',
'rules' => 'trim|required'
),
array(
'field' => 'email_address',
'label' => 'Email Address',
'rules' => 'trim|required|valid_email'
, 'errors'=> array('valid_email'=>'Please make sure your email is correct.')))