LoginForm::rules PHP Method

rules() public method

public rules ( ) : array
return array
    public function rules()
    {
        $module = Yii::app()->getModule('user');
        return [['email, password', 'required'], ['verifyCode', 'required', 'on' => self::LOGIN_LIMIT_SCENARIO], ['remember_me', 'boolean'], ['verifyCode', 'yupe\\components\\validators\\YRequiredValidator', 'allowEmpty' => !$module->showCaptcha || !CCaptcha::checkRequirements(), 'message' => Yii::t('UserModule.user', 'Check code incorrect'), 'on' => self::LOGIN_LIMIT_SCENARIO], ['verifyCode', 'captcha', 'allowEmpty' => !$module->showCaptcha || !CCaptcha::checkRequirements(), 'on' => self::LOGIN_LIMIT_SCENARIO], ['verifyCode', 'emptyOnInvalid']];
    }

Usage Example

コード例 #1
0
ファイル: LoginFormTest.php プロジェクト: netis-pl/yii-usr
 public function testWithBehavior()
 {
     $form = new LoginForm();
     $formAttributes = $form->attributeNames();
     $formRules = $form->rules();
     $formLabels = $form->attributeLabels();
     $form->attachBehavior('captcha', array('class' => 'CaptchaFormBehavior'));
     $behaviorAttributes = $form->asa('captcha')->attributeNames();
     $behaviorRules = $form->asa('captcha')->filterRules();
     $behaviorLabels = $form->asa('captcha')->attributeLabels();
     $this->assertEquals(array_merge($formAttributes, $behaviorAttributes), $form->attributeNames());
     $this->assertEquals(array_merge($formRules, $behaviorRules), $form->rules());
     $this->assertEquals(array_merge($formLabels, $behaviorLabels), $form->attributeLabels());
     $form->detachBehavior('captcha');
     $this->assertEquals($formAttributes, $form->attributeNames());
     $this->assertEquals($formAttributes, $form->attributeNames());
 }
All Usage Examples Of LoginForm::rules