<SOLVED> A typo in the access rules killed the captcha action before my breakpoints were reached.</SOLVED>
For no obvious reason yiic generated my skeleton app without the contact page. I’ve copied contact.php into my view/site folder and the page displays now, but the captcha image isn’t generated or displayed.
Stepping through the code it’s not obvious when [font=“Courier New”]CCaptchaAction [/font]should be instantiated and run, and none of the breakpoints I set in its [font=“Courier New”]run() [/font]or [font=“Courier New”]renderimage() [/font]are ever triggered.
The captcha class action was generated for SiteController, the [font=“Courier New”]if(extension_loaded(‘gd’))[/font] condition in the contact.php evaluates to true and the rest of the view code runs (e.g. [font=“Courier New”]echo HtmlEx::activeLabel($contact,‘verifyCode’);[/font])
Any suggestions? Even a pointer to where [font="Courier New"]CCaptchaAction[/font] is normally triggered would be helpful.
Do you have $this->widget(‘CCaptcha’) in the view?
<?php if(extension_loaded('gd')): ?>
<?php echo CHtml::activeLabel($contact,'verifyCode'); ?>
<?php $this->widget('CCaptcha'); ?>
<?php echo CHtml::activeTextField($contact,'verifyCode'); ?>
<p class="hint">Please enter the letters as they are shown in the image above.
<br/>Letters are not case-sensitive.</p>
<?php endif; ?>
Yes, thanks Tommy. I just compared my contact.php to your code block and they are identical.
I’ve stepped into [font=“Courier New”]$this->widget(‘CCaptcha’);[/font] and it seems to my naive eye that things go normally, but then at no point is CCaptchaAction invoked either.
The URL for “Get a new code” is “http://www/sandbox/social/index.php/site/contact#” – is that right? I would think that there would be some difference, but then perhaps it just reloads the page. The contact page source shows “<img id=“yw0” src=”/sandbox/social/index.php/site/captcha" alt="" />" but as far as I can tell, CCaptchaAction isn’t called.
So looking at the URL for the captcha image, it seems that when the browser requests the image from the server that actionCaptcha should be run, and the generated image returned directly via HTTP, perhaps never existing on disk…
<goes to look at apache access log>
Aha! The captcha action is requested, but one simple typo in the access rules and access is denied, and since an exception is thrown none of my break points were reached. I love it when the problem is that easy to fix.