class My_Form extends Zend_Form { ... $this->addElement('Captcha', 'cap', array( 'label' => 'Введите код на картинке * :', 'required' => true, 'disableLoadDefaultDecorators' => true, 'decorators' => array('Captcha', array('ViewScript', array( 'viewScript' => 'captcha.phtml', 'placement' => false, ))), 'captcha' => array( 'captcha' => 'image', 'width' => 100, 'height' => 50, 'name' => 'foo', 'wordLen' => 3, 'font' => '/path/to/fonts/arial.ttf', 'fontSize' => 18, 'imgDir' => '/path/to/images/captcha', 'imgUrl' => 'http://' . $_SERVER['HTTP_HOST'] . '/images/captcha/', 'timeout' => 300, 'lineNoiseLevel' => 0, 'dotNoiseLevel' => 0, 'messages' => array( 'badCaptcha' => 'Вы ввели неверный код' )) )); ... }
<div style="float: left;"> <label><?= $this->element->getLabel() ?></label> <input id="captcha" type="text" name="cap[input]" /> <? if ($this->element->hasErrors()): ?> <?= $this->formErrors($this->element->getMessages()) ?> <? endif; ?> <input type="hidden" name="cap[id]" value="<?= $this->element->getValue() ?>" /> </div> <div style="float: left;"> <?= $this->element->getCaptcha()->render() ?></div> <div class="clear"></div>