【发布时间】:2017-03-20 14:28:03
【问题描述】:
需要更改默认的 YII 错误摘要,
在特定表单字段中显示每个错误,如下图所示。
这是我的工作集属性()。
public function properties() {
return array(
'action' => url('/user/signup', array('dialog' => isset($_GET['dialog']) ? $_GET['dialog'] : 0)),
'elements' => array(
'firstName' => array('type' => 'text'),
'lastName' => array('type' => 'text'),
'email' => array('type' => 'text'),
'password' => array('type' => 'password'),
'passwordRepeat' => array('type' => 'password'),
'profile' => wm()->get('user.profile.helper')->form(),
'<hr />',
'termsAgree' => array(
'type' => 'checkbox',
'layout' => "<fieldset>{input}\n{label}\n{hint}\n{error}</fieldset>",
'uncheckValue' => '',
'required' => false,
'afterLabel' => '',
),
),
'buttons' => array(
'submit' => array('type' => 'submit',
'id'=>'signUpButton',
'label' => $this->t('Sign Up')),
),
'model' => $this->model
);
}
这是我的模型 rules():
public function rules()
{
return array(
array('email, password, passwordRepeat, firstName, lastName', 'required'),
array('firstName, lastName, email', 'length', 'max' => 250),
array('email', 'email'),
array('email', 'unique', 'className' => 'MUser', 'message' => $this->t('This email is already in use.')),
array('password', 'length', 'min' => 6),
array('passwordRepeat', 'compare', 'compareAttribute'=>'password'),
array('termsAgree', 'required', 'message' => $this->t('You must be agree to our Terms of Use and Privacy Policy to join this site.'))
);
}
【问题讨论】:
-
请发布一些代码.. 没有代码我们无法为您提供帮助
-
看这里官方docu
-
这个问题是针对 Yii1 还是 Yii2 的?
-
YII1 @scaisEdge
-
更新你的问题并添加相关的模型函数规则
标签: php validation yii