yii captcha не проверяет правильность

Я пытаюсь добавить капчу, используя yii в мою контактную форму, но есть некоторые проблемы с проверкой.

Моя модель

class ContactForm extends CFormModel { public $verifyCode; public function rules() { return array( array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements(),'on'=>'captchaRequired'), array('verifyCode', 'safe'), ); } } 

Код в моем контроллере

 public function filters() { return array( 'accessControl', ); } public function accessRules() { return array( array( 'allow', //allow all users to perform advertise and index action 'actions' => array('advertise','index', 'captcha'), 'users' => array('*'), ), ); } public function actions() { return array( // captcha action renders the CAPTCHA image displayed on the contact page 'captcha' => array( 'class' => 'CCaptchaAction', 'backColor' => 0xFFFFFF, 'testLimit'=> '2', ), ) } public actionAdvertise() { $model = new ContactForm; $model->scenario = 'captchaRequired'; if($model->validate()){ //some code } else { $this->render('advertise', array('model' => $model)); } } } 

Код в моем представлении advert.php

  <form action="" method="post"> <?php $form=$this->beginWidget('CActiveForm',array( 'id'=>'contact-form', 'enableAjaxValidation'=>false, )); ?> <?php if(CCaptcha::checkRequirements()){ ?> <div class="row"> <div class="contact_field_wrapper"> <?php echo '<b>ARE YOU HUMAN?</b><br />'.$form->labelEx($model, 'verifyCode'); ?> <div class="captcha user-captcha"> <?php $this->widget('CCaptcha',array( 'captchaAction'=>'site/captcha' )); ?> <?php echo $form->error($model, 'verifyCode'); ?> <?php echo '<br />'.$form->textField($model,'verifyCode'); ?> <div class="hint">Please enter the letters as they are shown in the image above.<br/> Letters are not case-sensitive. </div> </div> </div> </div> <?php } ?> <?php $this->endWidget(); ?> </form> 

Проблема в том, что $model->validate() возвращает false при вводе правильного кода. $model->getErrors() всегда возвращается. Код подтверждения неверен.