Zend Framework

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.

Zend Form with Display Groups

Zend Form with Display Groups

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

8 Responses to “Zend Form display groups and decorators with example”

  1. butters said

    hey, thanks for that nice example…

  2. again, Superb piece of work!

  3. Markus said

    This is madness? Why not use css?

  4. Zeno said

    How about a customisable view phtml for Zend_Form? Without setDecorator()

    http://www.yu.id.au/2008/12/customisable-zend-form/

  5. 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.

  6. [...] 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 [...]

  7. 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);
    }
    }

  8. dhayal said

    I dont know how to thank u…

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>