public function validatePassword($attribute, $params) { if (!$this->hasErrors()) { $user = Yii::$app->user->identity; if ($user->validatePassword($this->password)) { $this->addError($attribute, '新密码不可与当前密码相同。'); } } }