'', 'AfterElement' => '', ); public function __call($method, $args) { if ('getAdditionalHtml' == substr($method, 0, 17)) { $section = substr($method, 17); return $this->_getAdditionalHtml($section); } else if ('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)); } public function render($content) { /** @var $element Zend_Form_Element_Multi */ $element = $this->getElement(); $view = $element->getView(); if (null === $view) { throw new Zend_Form_Decorator_Exception('ViewHelper decorator cannot render without a registered view object'); } if (method_exists($element, 'getMultiOptions')) { $element->getMultiOptions(); } $helper = $this->getHelper(); $separator = $this->getSeparator(); $value = $this->getValue($element); $attribs = $this->getElementAttribs(); $name = $element->getFullyQualifiedName(); $id = $element->getId(); $attribs['id'] = $id; if (array_key_exists('beforeHelper', $attribs) && is_callable($attribs['beforeHelper'])) { call_user_func($attribs['beforeHelper'], [ 'separator' => &$separator, 'value' => &$value, 'attribs' => &$attribs, 'name' => &$name, 'id' => &$id, ]); unset($attribs['beforeHelper']); } $elementContent = $view->$helper($name, $value, $attribs, $element->options); switch ($this->getPlacement()) { case self::APPEND: return $content . $separator . $this->getAdditionalHtmlBeforeElement() . $elementContent . $this->getAdditionalHtmlAfterElement(); case self::PREPEND: return $this->getAdditionalHtmlBeforeElement() . $elementContent . $this->getAdditionalHtmlAfterElement() . $separator . $content; default: return $this->getAdditionalHtmlBeforeElement() . $elementContent . $this->getAdditionalHtmlAfterElement(); } } function setAdditionalHtml($options = array()) { 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 ''; } }