0
需要更改默認YII錯誤總結,如何自定義誼defualt錯誤彙總到單個錯誤
要顯示在特定形式字段中的每個錯誤如下圖像。
這裏是我的worklet屬性()。
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
);
}
這裏是我的規則()爲模型:
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.'))
);
}
請發佈一些代碼..我們無法幫助您無代碼 – Blueblazer172
在這裏查看官方[docu](http://www.yiiframework.com/doc-2.0/guide-input-validation.html#validating-輸入) – Blueblazer172
這個問題是針對Yii1還是Yii2? – scaisEdge