0

Is there any way to setup all my Zend_Forms with this ?

$this->element->setDecorators(array(
    'ViewHelper',
    'Errors',
    'Label',
    array('HtmlTag', array('tag' => 'div', 'id' => '[MyElementLabel]')));

Instead of do that one by one element of my Zend_forms? I mean something like a Form layout

Charles
  • 50,943
  • 13
  • 104
  • 142
grteibo
  • 607
  • 3
  • 11
  • 20

2 Answers2

2

The most concise way to override default decorators is by creating your own set of elements and overriding the loadDefaultDecorators() method.

You get Zend_Form to load your classes instead of it's own by adding your custom prefix path to it's plugin loader.

Here's some examples from my custom set of form elements

This is a little out of date as I haven't committed recent changes but the stuff you're looking for is applicable (plugin loader, default decorators, etc)

Phil
  • 157,677
  • 23
  • 242
  • 245
0

if you are looking for a way to handle Zend_Forms without dealing with the decorators (a quick and easy approach) check out: Zend_Form : data table with checkboxes

Ignore the checkbox stuff, the important part is laying out your form the way you want in your view (or in a partial if you want to reuse the form html) so pass the form to your view and call the elements into the html as needed.

Community
  • 1
  • 1
Francis Yaconiello
  • 10,829
  • 2
  • 35
  • 54