title: Yii - rule allowEmpty for model
body: <p>I have a standard model <code>LoginForm</code>, which uses a CAPTCHA to login. Anyway in some page i need login without captcha. For this i added <code>public $useCaptcha = true;</code>. When it's <code>false</code>, CAPTCHA don't need. I also added one rule:</p>
  
  <pre><code>array('verifyCode', 'captcha', 'allowEmpty'=&gt;!Yii::app()-&gt;user-&gt;isGuest || !CCaptcha::checkRequirements() || !$this-&gt;useCaptcha)
  </code></pre>
  
  <p>But my rule doesn't work. It's return always false. As solution i'm use <code>beforeValidation</code> function:</p>
  
  <pre><code>protected function beforeValidate()
  {
      if(!$this-&gt;useCaptcha)
      {
          $this-&gt;getValidators()[4]-&gt;allowEmpty = true;
      }
      return true;
  }
  </code></pre>
  
  <p>But this is not good decision. Why <code>allowEmpty</code> rule return <code>false</code>?</p>