Recaptcha not working when rest of the inputs are correct

I have a problem using recaptcha in my app. I have a registration form with username, email, password and recaptcha.

  1. If I fill in correct recaptcha and for example email is not filled, I got error about missing email, that’s OK

  2. If I fill in incorrect recaptcha and email is not filled, I got error wrong recaptcha and missing email, that’s also OK

  3. If I fill in correct recaptcha, and whole form is filled (correctly), I got error about wrong recaptcha. I tested multiple times, and that’s the problem.

I’m using recaptcha extension, and I’ve downloaded recaptchalib.php.

In my form I use it like this:


 <section>


                    <?php $this->widget('application.extensions.recaptcha.EReCaptcha',

                        array('model'=>$model, 'attribute'=>'verifyCode',

                            'theme'=>'red', 'language'=>'en',

                            'publicKey'=>'.....')) ?>

</section>

then in the model


public function rules() {

		$rules = array(

			array('username, password, verifyPassword, email', 'required'),

			...

            array('verifyCode',

                'application.extensions.recaptcha.EReCaptchaValidator',

                'privateKey'=>'....','message' => Yii::t("module_user","Wrong captcha."))


        );

		}

Could you please give me a hint what could be wrong? thanks.

Ok I’ve figured out, the validateAttribute method for the captcha was called twice, because I validated user model and then saved it (and saving contains also validation, so validation was called twice) and for the second time the captcha was empty.