views:

48

answers:

0

i currently set my default decorators for my Zend_Form using a class extending from Zend_Form ...

class Application_Form_Abstract extends Zend_Form {
    ... 
    function loadDefaultDecorators() {
        if ($this->loadDefaultDecoratorsIsDisabled()) {
            return $this;
        }

        // ... for elements
        $decorators = $this->_elementDecorators;
        if (empty($decorators)) {
            $this->setElementDecorators(array(
                'ViewHelper',
                'Errors',
                array('Description', array('tag' => 'p', 'escape' => false)),
                'Label',
                array('HtmlTag', array('tag' => 'p'))
            ));

but i soon realize that that way, i cannot define specific element decorators like

$this->addElement('textarea', 'bio', array(
    'decorators' => array(
        'ViewHelper',
        'Errors',
        array('Description', array('tag' => 'p', 'escape' => false)),
        'Label',
        array('HtmlTag', array('tag' => 'p')),
        new Application_Form_Decorator_WmdPreview,
     )
));

as they will be over-written by my custom loadDefaultDecorators() function. i wonder if there is any way i can set default decorators for element only if they have no set decorators