Zend Form display groups and decorators with example
Posted by Faheem Abbas on November 3, 2008
Sorry this blog is deprecated.
“Read new and updated version of this post here”. http://zendgeek.blogspot.com/2009/07/zend-form-display-groups-decorators.html
In my previous posts I discussed creation of zend form and decorators. These features are very helpful and quite easy to use.
However to give better look and feel to your form you will need to study Zend From display groups.
Display groups are used to group form elements for display purposes, so they give new look and feel to your forms. The name
of the form elements remain the same however elements in the same group are render together.
The most common use case would be to use display groups to put your form element in different field sets. Consider the following layout of the form.

butters said
hey, thanks for that nice example…
Ilyas Iqbal said
again, Superb piece of work!
Markus said
This is madness? Why not use css?
Zeno said
How about a customisable view phtml for Zend_Form? Without setDecorator()
http://www.yu.id.au/2008/12/customisable-zend-form/
Faheem Abbas said
Customizable view phtml can be used, but I feel it is better to handle form in seperate place rather than mixing it with the html.
You can achieve any functionality and can design your form whatever way you like in single place. This will help in modification and in maintenence.
Zend_Form - Zend Framework Forum said
[...] ye, everything is possible.. you can even group elements into divs and then float them around.. here is some good post about decorators and groups.. Decorators with Zend_Form Zend Form display groups and decorators with example Zend Framework [...]
Erik Seifert said
Easy way for global handling decorators
class My_Form extends Zend_Form
{
public function addElement($element, $name = null, $options = null)
{
if ( is_string('element') )
{
$element = $this->createElement($element, $name, $options);
$element->removeDecorator('DtDdWrapper');
$element->removeDecorator('Label');
$element->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'zend_form'));
$element->addDecorator('Label', array('tag' => 'div', 'class' => 'zend_form'));
}
parent::addElement($element);
}
}
dhayal said
I dont know how to thank u…