Jump to content
Larry Ullman's Book Forums

Captcha On Every Page


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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...