Reputation: 81
In the new Zend Framework version 1.11.9 if I want to use a captcha in my form this can be a simple Figlet, the captcha is not shown in the rendered form. Has anyone encountered this issue, I've been searching and comparing it with the previous release, (Zend/Form/Element/Captcha.php) and what i noticed is that I must specify the Captcha decorator for this element. Is there a better solution, shouldn't this decorator been used by default?
//Add a captcha
$this->addElement('captcha', 'captcha', array(
'label' => 'Please enter the 5 letters displayed below:',
'required' => true,
'captcha' => array(
'captcha' => 'Figlet',
'wordLen' => 5,
'timeout' => 300
)
));
This is the code, if I use this in Zend 1.11.9 the capctha is not displayed, What I had to do was to add 'decorators' to the options of teh capctha and had to specify there all the decorators.
//Add a captcha
$this->addElement('captcha', 'captcha', array(
'label' => 'Please enter the 5 letters displayed below:',
'required' => true,
'captcha' => array(
'captcha' => 'Figlet',
'wordLen' => 5,
'timeout' => 300
),
'decorators' => array('Captcha', 'Errors', 'Labels', etc)
));
Upvotes: 3
Views: 2533
Reputation: 229
I'm using the latest version of ZF and
$captchaElement = new Zend_Form_Element_Captcha
(
'signup',
array('captcha' => array(
'captcha' => 'Figlet',
'wordLen' => 6,
'timeout' => 600,
))
);
Show nothing =-(
This is the source on the page:
<dt id="signup-input-label"><label for="signup-input" class="required">Please type in the words below to continue</label></dt>
<dd id="signup-element">
<input type="hidden" name="signup[id]" value="9038166aac96370c73b9d474e8e20475" id="signup-id">
<input type="text" name="signup[input]" id="signup-input" value="">
Upvotes: 0
Reputation: 1852
I've encountered the same problem. Posted a bug report on Zend Framework issue tracker: http://framework.zend.com/issues/browse/ZF-11609
Hope it will get resolved soon. I've checked the 1.11.9 changelog: there was a change at the recaptcha component. Maybe that's the reason...
Upvotes: 3
Reputation: 106
I can confirm this. To show you some code, in ZF 1.11.8 this works out of the box:
$captcha = new Zend_Form_Element_Captcha('captcha', array(
'label' => 'Security Check',
'required' => true,
'captcha' => array(
'captcha' => 'Image',
'font' => APPLICATION_PATH . '/../data/fonts/AllerDisplay.ttf',
'fontSize' => '24',
'wordLen' => 6,
'height' => '50',
'width' => '150',
'imgDir' => APPLICATION_PATH . '/../public/images/captcha',
'imgUrl' => Zend_Controller_Front::getInstance()->getBaseUrl() . '/images/captcha',
)
));
In 1.11.9 it doesn't render the image tag. This behavoir is not limited to Zend_Captcha_Image as stated by the thread opener.
Upvotes: 0