LoginForm::rules PHP 메소드

rules() 공개 메소드

public rules ( ) : array
리턴 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
 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