Adding Captcha Validator into validator List


I am using capcha only one of my action. That a reason I add the validator into beforeValidation. The problem is validation always return "Verify Cod is incorrect" error message

Any idea. Thanks

public function beforeValidate() {


                $validator = new CCaptchaValidator();




                $validator->attributes = array('verifyCode');





            return parent::beforeValidate();


don’t think accessing controller from model is a good way (think about in console application what will happen )! MVC is consider a layer design pattern . so don’t access higher layer , only one direction accessing is to advocate .

to define a scenario for actionForgetPassword . or you dynamically add the validator to the model in you forgetPassword function . i never thought we can add validator in runtime :lol: , thank you umutau

Thanks it solved