Jump to content
Larry Ullman's Book Forums

Captcha On Every Page


Stuart
 Share

Recommended Posts

Hi,

 

Not been on here in a while! Doing lots of Yii work though so should be able to start helping people out now the books out. Bought a copy last week - only had chance to browse and already looks like it explains concepts far better than the other Yii book I have!

 

I want to render a form inside a modal window that is part of the main.php layout file. The form needs a CAPTCHA which is where my problems start.

 

Adding a CAPTCHA directly to an action's view works fine but as soon as I try and do it from main.php I'm running into all kinds of problems.

 

It seems unless I'm on the page the form points to I have to enter the CAPTCHA twice - some issue where the value must be getting set twice/overwritten?

 

At the moment I've had to add the action and access filter to all of my controllers (which I know is disgusting) but I can't see how to make this work?

 

Thanks

 

Stuart

Link to comment
Share on other sites

After posting I decided to stop reading forums and the docs and jump into the source code. You simply have to set the captchaAction using a route:

 

$this->widget('CCaptcha', array('captchaAction'=>'feedback/captcha'));

 

This wasn't that apparent to me when reading the docs but the source code comments provide an explicit example. So now I can render the CAPTCHA widget in the main.php and it works great! Sorry for wasting people's time who read this... its been a long few days :unsure:

  • Upvote 2
Link to comment
Share on other sites

 Share

×
×
  • Create New...