this may help you. Just extends the Zend_Form once somewhere in your library
directory. Extend your forms with My_Form.

something like this

class My_Form extends Zend_Form
{
    public $elementDecorators = array(
        'ViewHelper',
        'Errors',
        array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' =>
'element')),
        array('Label', array('requiredSuffix' => ' *', 'tag' => 'td')),
        array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
    );

    public $buttonDecorators = array(
        'ViewHelper',
        array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' =>
'element')),
        array(array('label' => 'HtmlTag'), array('tag' => 'td', 'placement'
=> 'prepend')),
        array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
    );
    
    public $formDecorators = array(
        'FormElements',
        array('HtmlTag', array('tag' => 'table')),
        'Form'
    );

    public function __construct($action='#', $description='')
    {
        parent::__construct();
        
        $this->setAttrib('accept-charset', 'UTF-8');
        $this->setAction($action)
             ->setMethod('post')
             ->setLegend($description)
             ->setDisableLoadDefaultDecorators(true)
             ->setDecorators($this->formDecorators);
        $this->setName('form_' .
Zend_Controller_Front::getInstance()->getRequest()->getModuleName());
        $this->setAttrib('enctype', 'multipart/form-data');
        $this->setAttrib('onsubmit', 'javascript:switchImageOn();return
true;');
        $this->clearDisplayGroups();
    }
    public function createElement($type, $name, $options = null)
    {
        $element = parent::createElement($type, $name, $options);
        
        if(($type == 'button') || ($type == 'submit') )
        {
            $decorators = $this->buttonDecorators;
        }
        else
        {
            $decorators = $this->elementDecorators;
        }
        
                $element->setDecorators($decorators);
        
        return $element;
    }
}

and then...

class Relatie_BedrijfForm extends My_Form {
...
}


R! wrote:
> 
> Hi,
> I§m wonder if there is any simple way how to change default decorators for
> Zend_Form_Element without extending all of them. I have quite large
> project with a lto of forms and default decorators isn't whati want. Maybe
> something like Zend_Form_Element::setDefaultDecorators() will be great for
> me but this methos is curently missing and as I wrote before extending all
> single one element isnt very comfortable.
> any ideas?
> 
> Thanks
> 


-----
visit my website at  http://www.phpscriptor.com/ http://www.phpscriptor.com/ 
-- 
View this message in context: 
http://www.nabble.com/Zend_Form_Element-default-decorators-tp23719512p23720113.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to