/** * Check the username exist or not * This method serves as the inline validation for username. * * @param string $attribute the attribute currently being validated * @param array $params the additional name-value pairs given in the rule */ public function checkEmailExists($attribute, $params) { if (!$this->hasErrors()) { if (!User::checkEmailExist($this->id, $this->email)) { $this->addError($attribute, Yii::t('app', 'This email address has already been taken.')); } } }