/** * Add element to stack * * @param \Zend_Form_Element $element * @return \Zend_Form_DisplayGroup */ public function addElement(\Zend_Form_Element $element) { $decorators = $element->getDecorators(); $decorator = array_shift($decorators); $element->setDecorators(array($decorator, array('Description', array('class' => 'description')), 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')), array('Label'), array(array('labelCell' => 'HtmlTag'), array('tag' => 'td', 'class' => 'label')), array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'class' => $this->_alternate)))); return parent::addElement($element); }
/** * Retrieve all decorators * * @throws ZendX_JQuery_Form_Exception * @return array */ public function getDecorators() { $decorators = parent::getDecorators(); if (count($decorators) > 0) { // Only check this if there are decorators present, otherwise it could // be that the decorators have not been initialized yet. $foundUiWidgetElementMarker = false; foreach ($decorators as $decorator) { if ($decorator instanceof ZendX_JQuery_Form_Decorator_UiWidgetElementMarker) { $foundUiWidgetElementMarker = true; } } if ($foundUiWidgetElementMarker === false) { require_once "ZendX/JQuery/Form/Exception.php"; throw new ZendX_JQuery_Form_Exception("Cannot render jQuery form element without at least one decorator " . "implementing the 'ZendX_JQuery_Form_Decorator_UiWidgetElementMarker' interface. " . "Default decorator for this marker interface is the 'ZendX_JQuery_Form_Decorator_UiWidgetElement'. " . "Hint: The ViewHelper decorator does not render jQuery elements correctly."); } } return $decorators; }
public function testCanDisableRegisteringDefaultDecoratorsDuringInitialization() { $element = new Zend_Form_Element('foo', array('disableLoadDefaultDecorators' => true)); $decorators = $element->getDecorators(); $this->assertEquals(array(), $decorators); }