The Captcha images are being created so i suspect its the path to the images
from the view scripts that is the problem. Is your path to your image in the
view code accessible by a browser?
I always use an absolute path from my web root (public or public html
directory).
For instance if you have a folder in the root of your site for images, then
/images/captcha/
would be your folder, etc.
Try specifying an absolute path from the web directory root.
Deepak Shrestha wrote:
On Tue, Jan 27, 2009 at 3:24 PM, Deepak Shrestha d88...@gmail.com wrote:
Hi,
Didn't get any help from my last post so I went through documentation
and tried to understand as much I can but can't find a way to display
captcha image in Zend_Form using default behavior of Zend Framework's
MVC. AFAIK (with my current knowledge), my code is correct.
This is the code snippet in my [application/forms/myform.php]
===
//first create an image type captcha
$captchaimg = New Zend_Captcha_Image('captchaimg');
$captchaimg-setFont(../application/captcha/fonts/tahoma.ttf);
$captchaimg-setImgDir(../application/captcha/images);
$captchaimg-setImgUrl(../application/captcha/images);
$captchaimg-setWordlen('6');
//create user input for captcha and include the captchaimg in form
$adcaptcha = New Zend_Form_Element_Captcha('adcaptcha', array(
'captcha' = $captchaimg));
$adcaptcha-setLabel('Please enter the 5 letters displayed
below:');
$adcaptcha-setRequired(true);
$adcaptcha-addErrorMessage('Entered value did not match with
displayed image.');
$this-addElements( array($adcaptcha));
=
My view script:
?= $this-form ?
dirctory structure for captcha image is:
=
application
- captcha
- fonts
- images (for genreated images)
=
My Observation
===
1. There is no captcha image when form renders. However, I can see
image being generated in 'application/captcha/images' folder.
2. Trying to post the empty form (expecting that my custom error
message will be displayed) gives me empty error message string with
just a round bullet list in the captcha section but other text input
fields show the correct error messages.
3. Using view source in the browser, i got this about captcha
*
dd
../application/captcha/images/641aa987b887cbefb441f33e194a45b9.png br/
input type=hidden name=adcaptcha[id]
value=641aa987b887cbefb441f33e194a45b9 helper=formText
id=adcaptcha-id /
input type=text name=adcaptcha[input] id=adcaptcha-input
value= helper=formText //dd
**
===
My Questions:
1. The image url was passed to the brower but why it didn't get
rendered in the form?
2. Is this the bug or feature? If it is the feature, how do I make the
image appear in my form using the code I have posted above? what are
the additional things I need to consider?
Partial answer (best guess) to my own question:
1. Probably form is forgetting to call some default rendering function
of Zend_Captcha to render it (or ???). However custom approach (with
custom form) as shown in zend documentation
[http://framework.zend.com/manual/en/zend.captcha.operation.html] and
the one I found in recent blog [http://www.tfountain.co.uk/] works
because it explicitly calls echo $captcha-render($view); method.
But I want to stick with ZF's default MVC behaviors and want to
understand how these pieces fit together before I can understand and
do customized stuffs. So I need to show the captcha image suing zend
form.
Can somebody guide me about whether it is bug/feature? and any
workaround?
Thanks a lot
Sorry I forgot to mention that I am using current version of ZF 1.7
Thanks
--
===
Registered Linux User #460714
Currently Using Fedora 8, 10
===
--
View this message in context:
http://www.nabble.com/Zend_Form-or-Captcha-bug--tp21680760p21681645.html
Sent from the Zend Framework mailing list archive at Nabble.com.