Yii Framework Forum: CCaptchaValidator.action "captcha" is invalid. Unable to find such an action in the current controller. - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CCaptchaValidator.action "captcha" is invalid. Unable to find such an action in the current controller. Rate Topic: -----

#1 User is offline   Marcolini 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 16-March 12
  • Location:Portugal

Posted 14 August 2012 - 10:36 AM

Hi all.
I have a problem i would like to solve and appreciate any help :)
here it goes:

In my application i have two models: Project and User.
What im trying to do is when a user creates a project, i want to increment a property of the user createdProjects+1.

So, what i did was in the ProjectController:
public function actionCreate()
{
   $modelProject = new Project;
   $modelUser = User::model()->findByPk(Yii::app()->user->id);
               //gets the model of the user Logged

   ...

   if ($modelProject->validate())
   {
      $modelUser->createdProjects = $modelUser->createdProjects + 1;
      $modelUser->save();
   }
   ...
}


An Exception is thrown:
"CCaptchaValidator.action "captcha" is invalid. Unable to find such an action in the current controller."
in the line $modelUser->save() when i try to update the User counter.

What am i doing wrong?
Thank you for your time.
0

#2 User is offline   Marcolini 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 16-March 12
  • Location:Portugal

Posted 16 August 2012 - 05:13 AM

Any tips?
0

#3 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,523
  • Joined: 12-October 09
  • Location:Croatia

Posted 16 August 2012 - 05:25 AM

Some questions that comes to mind:

- what are your validation rules...
- do you need it at all...
- if yes, did you define the captcha action...
Find more about me.... btw. Do you know your WAN IP?
0

#4 User is offline   Marcolini 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 16-March 12
  • Location:Portugal

Posted 16 August 2012 - 05:42 AM

View Postmdomba, on 16 August 2012 - 05:25 AM, said:

Some questions that comes to mind:

- what are your validation rules...
- do you need it at all...
- if yes, did you define the captcha action...


Didnt understand ur questions at all...
i do the validation() before the save() to avoid rollbacks. First i validate all the models and then save all at once.
0

#5 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,523
  • Joined: 12-October 09
  • Location:Croatia

Posted 16 August 2012 - 05:51 AM

The error message say "CCaptchaValidator"... so you have "some" problem with this validator... what I asked you is if you have that validatior in your model validation rules or maybe it's there by error... if you have it... than you need to have the action "captcha" defined in your controller... do you have it?

For an example... check the default code generated by Gii... the captcha validator is used in the model ContactForm and the "captcha" action is defined in the controller SiteController.
Find more about me.... btw. Do you know your WAN IP?
0

#6 User is offline   Marcolini 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 16-March 12
  • Location:Portugal

Posted 16 August 2012 - 06:39 AM

Did solve my problem :)

http://www.yiiframew...-loading-model/

Thank you for your time
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users