*Enter code above'; protected $_additionalHtml = [ 'BeforeElement' => '', 'AfterElement' => '', 'BeforeInput' => '', ]; public function __call($method, $args) { if ('getAdditionalHtml' == substr($method, 0, 17)) { $section = substr($method, 17); return $this->_getAdditionalHtml($section); } elseif ('setAdditionalHtml' == substr($method, 0, 17)) { $section = substr($method, 17); return $this->_setAdditionalHtml($section, $args[0]); } throw new Zend_Form_Decorator_Exception(sprintf('Method %s does not exist', $method)); } function setAdditionalHtml($options = []) { foreach ($options as $section => $html) { $this->_setAdditionalHtml($section, $html); } return $this; } protected function _setAdditionalHtml($section, $html) { if (!isset($this->_additionalHtml[$section])) { throw new Zend_Form_Decorator_Exception('Invalid section for decorator additional HTML'); } $this->_additionalHtml[$section] = $html; return $this; } protected function _getAdditionalHtml($section = null) { if (empty($section)) { return $this->_additionalHtml; } if (isset($this->_additionalHtml[$section])) { return $this->_additionalHtml[$section]; } return ''; } public function initRender() { $id = $this->getElement()->getId() . '-input'; $params = [ 'useWrapper' => true, 'elements' => [ ['selector' => '#' . $id, 'hint' => $this->_hint], ], ]; /** @var $doc Qs_Doc */ $doc = Zend_Registry::get('doc'); $doc->addScript('js/jquery.defaultHint.js'); $doc->addInitFunction('$().defaultHint', [$params]); return $this; } /** * Render captcha * * @param string $content * @return string */ public function render($content) { /** @var Zend_Form_Element $element */ $element = $this->getElement(); /** @var Qs_View $view */ $view = $element->getView(); if (null === $view) { return $content; } $name = $element->getFullyQualifiedName(); $hiddenName = $name . '[id]'; $textName = $name . '[input]'; $placement = $this->getPlacement(); $separator = $this->getSeparator(); $attribs = $element->getAttribs(); $attribs = Qs_Array::excludeKey($attribs, 'helper', 'captchaOptions'); $attribs['id'] = $element->getId() . '-input'; $text = $view->formText($textName, '', $attribs); $attribs['id'] = $element->getId() . '-hidden'; $hidden = $view->formHidden($hiddenName, $element->getValue(), $attribs); switch ($placement) { case 'PREPEND': $content = $this->getAdditionalHtmlBeforeElement() . $hidden . $separator . $this->getAdditionalHtmlBeforeInput() . $text . $separator . $this->getAdditionalHtmlAfterElement() . $content; break; case 'APPEND': default: $content = $content . $this->getAdditionalHtmlBeforeElement() . $hidden . $separator . $this->getAdditionalHtmlBeforeInput() . $text . $separator . $this->getAdditionalHtmlAfterElement(); } return $content; } }