On 29 Feb 2008, at 14:06, Matthew Weier O'Phinney wrote:


One thing you may want to try is setting the decorators you want to use
as an independent array. For instance:

   $decorators = array(
       'ViewHelper',
       'Errors',
       'Label'
       array('HtmlTag', array('tag' => 'div', 'class' => 'element'))
   );

You could then use this array when instantiating your elements or using
the factory:
[snip]

   // or

   $form->addElement('text', 'email', array(
       'label'      => 'Email Address',
       'size'       => '30',
       'decorators' => $decorators,
   ));


I essentially do this - wrapped up in an extension to Zend_Form.

I have extended Zend_Form to create App_Form which overrides addElement() to add in $options['decorators'] if not already set and then call through to the parents addElement(). I then have two sets of "standard" decorators: one for buttons and one for everything else as I don't want labels decorating my buttons.


Regards,

Rob...

Reply via email to