Skip to content

Three Zend_Form tips

2009 July 21
by Richard Knop

I have compiled a short list of Zend_Form tips I find very useful yet are not mentioned in the documentation and are hard to come across (unless you want to spend hours digging old Nabble threads):

Checkbox label placement

The default checkbox placement is on the right side of its label. This can be easily changed by setting the placement option of the Label decorator (allowed values are APPEND and PREPEND):

$element->addDecorator('Label', array('placement' => 'APPEND'));

Inline radio buttons

By default radio buttons are separated with <br /> tags which causes every radio button to display on a single line. To display all radio buttons on a single line:


Unescaped labels

Sometimes you will need to display a link (or any other XHTML markup) inside labels:

$element->addDecorator('Label', array('escape' => false));
2 Responses leave one →
  1. February 19, 2010

    Great tips!

    Using setSeparator was really useful to me!
    Just want to mention how useful it is to do create everything in one go:

    $this->addElement('radio', '<name>', array(
    'label' => '<label>',
    'decorators' => array('ViewHelper',
    array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')),
    array(array('td' => 'HtmlTag'), array('tag' => 'td')),
    array('Label', array('tag' => 'td'))
    'multiOptions' => array(
    '<option1>' => '<option1 label>',
    '<option2>' => '<option2 label>',
    separator => ''


  2. Michael permalink
    January 11, 2013

    Wow, by far this was the most helpfull Article I read in 2013. Ok, it’s only the 11th of 365 days, but anyway, super short and informative article. Thanks

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS