Reputation: 1
How can I create a captcha field when I have created the form using conventional html rather than the addElement() methods of ZF? That might sound stupid, but i'm a novice and after 6 hours of straight googling, still no answer.
Upvotes: 0
Views: 340
Reputation: 8519
I was able to add a captcha directly to the view using this code:
<?php
$form = new Zend_Form();
$captcha = new Zend_Form_Element_Captcha('Captcha', array(
'captcha' => array(
'captcha' => 'Image',
'wordLen' => 6,
'timeout' => 300,
'width' => 300,
'height' => 100,
'imgUrl' => '/captcha',
'imgDir' => APPLICATION_PATH . '/../public/captcha',
'font' => APPLICATION_PATH . '/../public/fonts/LiberationSansRegular.ttf')));
$form->addElement($captcha);
echo $form;//use this line in view script
$this->view->form = $form //use this line in controller
?>
you could also put the same code into your controller, assign it to the view and then call it in the view like:
<form>
//form stuff html
<?php echo $this->form->captcha ?>
</form>
Upvotes: 2