重复密码在 Yii2 中不起作用
我在模型中编写了规则:
public $password_repeat;
/**
* @inheritdoc
*/
public function rules()
{
return [
....
....
['password', 'required'],
['password', 'string', 'min' => 6],
['password_repeat', 'compare', 'compareAttribute'=>'password', 'message'=>"Passwords don't match" ],
];
}
如果我在和字段中使用不同的密码,则会出现错误。所以,这意味着它有效。但问题是,如果字段为空,它不会给出任何错误。Password
Password Repeat
Password Repeat