我是CodeIgniter(v 3.0.0)的新手(来自Cake
PHP),我正在尝试将自定义验证错误消息设置为我的一个表单.我正在使用配置文件存储我的所有验证规则,如
here所述.这是我的application / config / form_validation.PHP文件:
原文链接:https://www.f2er.com/php/134706.html<?PHP if (!defined('BASEPATH')) exit('No direct script access allowed'); $config = array( 'appointments/signup' => array( array( 'field' => 'admin[name]','label' => 'Name','rules' => 'required','errors' => array( 'required' => 'Please tell us your %s',),array( 'field' => 'admin[email]','label' => 'Email','rules' => 'required|valid_email|is_unique[users.email]','errors' => array( 'required' => 'Please enter your %s address','valid_email' => 'Please enter a valid email address','is_unique' => 'That email is already taken. Forgot your password?' ) ),array( 'field' => 'admin[username]','label' => 'Username','rules' => 'required|min_length[4]|max_length[25]|is_unique[user_settings.username]','errors' => array( 'required' => 'Please choose a %s','min_length' => '%s must me at least 4 characters long','max_length' => '%s cannot exceen 25 characters','is_unique' => '%s is already taken :(' ) ),array( 'field' => 'admin[phone_number]','label' => 'Phone number','rules' => 'min_length[0]',array( 'field' => 'admin[password]','label' => 'Password','rules' => 'required|min_length[8]','min_length' => '%s must be at least 8 characters long' ) ),array( 'field' => 'admin[passconf]','rules' => 'required|matches[admin[password]]','errors' => array( 'required' => 'Please re-type your %s','matches' => '%ss do not match' ) ),array( 'field' => 'company[company_name]','label' => 'Organization\'s Name',) ),);
正如您所看到的,我正在尝试使用errors数组设置自定义验证反馈,详见here.但我仍然看到全局默认值<字段名称>字段是必需的.信息.