大佬教程收集整理的这篇文章主要介绍了验证 – Yii2比较验证器警报不消失,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的规则代码在模型
public function rules() { return [ ['username','filter','filter' => 'trim'],['username','required'],'unique','targetClass' => '\common\models\User','message' => 'This username has already been taken.'],'string','min' => 2,'max' => 255],['email','email'],'message' => 'This email address has already been taken.'],['password','compare'],'min' => 6],['password_repeat','safe'] ]; }
和我的表格
<?PHP $form = ActiveForm::begin(); ?> <h3>Your Account</h3> <?= $form->field($modelUser,'username')->textInput(['maxlength' => 45,'class' => 'input-xlarge form-control']) ?> <?= $form->field($modelUser,'password')->passwordInput(['class' => 'form-control input-xlarge']) ?> <?= $form->field($modelUser,'password_repeat')->passwordInput(['class' => 'form-control input-xlarge']) ?> <button class="btn btn-primary" type="submit">Continue</button> <?PHP ActiveForm::end(); ?>
这是我的截图
['password',
到这个:
['password_repeat','compare','compareAttribute' => 'password'],
以上是大佬教程为你收集整理的验证 – Yii2比较验证器警报不消失全部内容,希望文章能够帮你解决验证 – Yii2比较验证器警报不消失所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。