Decorate an element by using a view helper to render it.
Accepts the following options:
- separator: string with which to separate passed in content and generated content
- placement: whether to append or prepend the generated content to the passed in content
- helper: the name of the view helper to use
Assumes the view helper accepts three parameters, the name, value, and
optional attributes; these will be provided by the element.
public function render($content) { $element = $this->getElement(); $view = $element->getView(); $helper = $this->getHelper(); $helperObject = $view->getHelper($helper); // var_dump($element); $helperObject->setForm($view->form); return parent::render($content); }
/** * Get element attributes * * @return array */ public function getElementAttribs() { if (null === $this->_attribs) { $this->_attribs = parent::getElementAttribs(); if (array_key_exists('dijitParams', $this->_attribs)) { $this->setDijitParams($this->_attribs['dijitParams']); unset($this->_attribs['dijitParams']); } } return $this->_attribs; }
/** * Retrieve element attributes * * Set id to element name and/or array item. * * @return array */ public function getElementAttribs() { $attribs = parent::getElementAttribs(); unset($attribs['addon_append']); // Twitter_Bootstrap3_Form_Decorator_Addon unset($attribs['addon_prepend']); // Twitter_Bootstrap3_Form_Decorator_Addon unset($attribs['success']); // Twitter_Bootstrap3_Form_Decorator_Container unset($attribs['warning']); // Twitter_Bootstrap3_Form_Decorator_Container return $attribs; }
/** * Retrieve element attributes * * Set id to element name and/or array item. * * @return array */ public function getElementAttribs() { $attribs = parent::getElementAttribs(); $element = $this->getElement(); if ($element->isRequired()) { $element->setAttrib('required', 'required'); $element->setAttrib('aria-required', 'true'); $attribs['required'] = 'required'; $attribs['aria-required'] = 'true'; } if ($element->hasErrors()) { $element->setAttrib('aria-invalid', 'true'); $attribs['aria-invalid'] = 'true'; } return $attribs; }
/** * Retrieve element attributes * * Set id to element name and/or array item. * * @return array */ public function getElementAttribs() { $attribs = parent::getElementAttribs(); unset($attribs['addon_append']); // Twitter_Bootstrap3_Form_Decorator_Addon unset($attribs['addon_prepend']); // Twitter_Bootstrap3_Form_Decorator_Addon unset($attribs['success']); // Twitter_Bootstrap3_Form_Decorator_Container unset($attribs['warning']); // Twitter_Bootstrap3_Form_Decorator_Container //Remove dimensions if any unset($attribs['dimensionLabel']); unset($attribs['dimensionControls']); unset($attribs['dimension']); unset($attribs['formgroupclass']); return $attribs; }
public function getHelper() { if ($this->isViewOnlyEnabled()) { $element = $this->getElement(); if (method_exists($element, 'getStaticViewHelper')) { $helper = $element->getStaticViewHelper(); } else { $type = $element->getType(); if ($pos = strrpos($type, '_')) { $type = substr($type, $pos + 1); } $helper = 'viewForm' . ucfirst($type); try { $element->getView()->getHelper($helper); } catch (Zend_Loader_PluginLoader_Exception $zlpe) { $helper = 'viewFormDefault'; } } $this->setHelper($helper); return $this->_helper; } else { return parent::getHelper(); } }
public function render($content) { $this->getElement()->setValue(''); return parent::render($content); }
/** * @param $button * @return string */ protected function renderButton($button) { $name = $button->getName(); $elementId = $button->getId(); $decorator = new Zend_Form_Decorator_ViewHelper(); $decorator->setElement($button); $markup = "<span class=\"data-wrapper {$name}-data\">" . "<span class=\"field\" id=\"{$elementId}-element\">" . $decorator->render(null) . '</span></span>'; return $markup; }
/** * Set a single option * * @param string $key * @param mixed $value * @return \Zend_Form_Decorator_Interface */ public function setOption($key, $value) { switch ($key) { case 'cellDecorator': $value = $this->getCellDecorators() + array($value); case 'cellDecorators': $this->_cellDecorators = $value; break; default: parent::setOption($key, $value); break; } return $this; }
public function render($content) { $elementContent = parent::render($content); return "<div class='radios'>{$elementContent}</div>"; }
public function buildInput($content) { $dec = new Zend_Form_Decorator_ViewHelper(); $dec->setElement($this->getElement()); return $dec->render($content); }