Jan 19 2011

Using Zend_Form_Decorators to compose a form as table rows

Ahh Zend form decorators, they certainly have a reputation of being quite difficult to pick up. I suffered similar problems but persevered to get the table layout I wanted.

    array('Description', array('tag' => 'span')),
    array('HtmlTag', array('tag' => 'td')),
    array('Label', array('tag' => 'th', 'requiredSuffix' => ' *')),
    array(array('row' => 'HtmlTag'), array('tag' => 'tr')),

The above code will result in the following (albeit not quite as neatly):

    <th>Label *</th>
        <input type="text" /><span class="hint">Description</span>
        <ul class="errors"><li>Error</li></ul>

For reference example was written with Zend Framework 1.11.2.

comments powered by Disqus


I'm Ade Slade, a PHP web developer.