ACC SHELL
<?php
class TF_Form_Element_Antispam extends Zend_Form_Element_Text
{
protected $_word = 'captcha me';
/**
* Set captcha adapter
*
* @param string|array|Zend_Captcha_Adapter $captcha
* @param array $options
*/
public function __construct ($spec, $options = null)
{
parent::__construct($spec, $options);
if ($options['word']) {
$this->_word = $options['word'];
}
$this->setAllowEmpty(true)->setRequired(true)->setAutoInsertNotEmptyValidator(false)->addValidator(
new Zend_Validate_Identical($this->_word), true);
}
public function render (Zend_View_Interface $view = null)
{
parent::render($view);
$id = $this->getName();
$v = $this->getView();
//ZendX_JQuery::enableView($v);
//$v->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper_');
$v->jQuery()->enable();
$v->jQuery()->addOnLoad("$('#spam{$id}Div').hide();");
$v->jQuery()->addOnLoad("$('#{$id}').val('$this->_word');");
//$v->headScript(Zend_View_Helper_HeadScript::SCRIPT,$script,'APPEND',array('useCdata'=>false,));
return '<div id="spam' . $id . 'Div">Vyplňte prosím do tohoto políčka "' . $this->_word .
'" - jedná se o ochranu proti robotům zasílajícím spam. <br />' . $this->getDecorator('viewHelper')->setElement(
$this)->render('') . '</div>';
}
}
ACC SHELL 2018