public function rules() { $runtimeRules = []; switch ($this->scenario) { case 'login': $runtimeRules = [['password', 'required', 'message' => Yii::t('user', 'Enter your password')], ['password', AccessValidator::className()], ['rememberMe', 'boolean']]; break; case 'forgotPassword': $runtimeRules = [['login', ContainsLoginValidator::className()]]; break; case 'personalArea': $runtimeRules = [['password', 'required', 'message' => Yii::t('user', 'Enter your password')], ['password', 'string', 'length' => [6, 16]], ['firstName', 'required'], ['familyName', 'required'], ['patronymic', 'required'], ['gender', 'required', 'message' => Yii::t('registration', 'Need to select gender')], ['phoneInput', 'required'], ['phoneInput', 'match', 'pattern' => '/^[0-9]+$/'], ['phoneInput', 'string', 'length' => 11], ['dayOfBirth', 'safe'], ['monthOfBirth', 'safe'], ['yearOfBirth', 'safe'], ['country', 'safe'], ['login', UniqueLoginValidator2::className()]]; break; case 'registration': $runtimeRules = [['password', 'required', 'message' => Yii::t('user', 'Enter your password')], ['password', 'string', 'length' => [6, 16]], ['login', UniqueLoginValidator::className()], ['firstName', 'required'], ['familyName', 'required'], ['patronymic', 'required'], ['gender', 'required', 'message' => Yii::t('registration', 'Need to select gender')], ['phoneInput', 'required'], ['phoneInput', 'match', 'pattern' => '/^[0-9]+$/'], ['phoneInput', 'string', 'length' => 11], ['blabla', 'boolean', 'falseValue' => 1, 'message' => Yii::t('registration', 'Confirm checkbox')], ['captcha', 'captcha'], ['captcha', 'required'], ['comment', 'safe'], ['school', 'required'], ['group', 'required'], ['dayOfBirth', 'required'], ['monthOfBirth', 'required'], ['yearOfBirth', 'required'], ['country', 'safe']]; break; case 'selectschool': $runtimeRules = [['school', 'safe']]; break; } return array_merge(parent::rules(), $runtimeRules); }