Zend Form Decorators
Decorators are used to render the various form objects (such as the elements, display groups, or the form itself). Most are optional, and nearly all of them come with customisable options.
By default the Zend_Form object will render the form with a definition list.
The <dl> tag is used in conjunction with <dt> (defines the item in the list) and <dd> (describes the item in the list).
Likewise, the Zend_Form_Element_* obejcts render with a definition description (dd), and if you use a label, a definition title (dt).
Here is the php code for the example above:
‘label’ => ‘username’
To remove the dl, dt and dd tags, we explicitly tell our form to use a different set of decorators:
//render our form elements and the “form” tag
//Tell all of our form elements to render only itself and the label
The output this time is a lot cleaner:
In this post I have shown how to remove the default decorators from your Zend_Form object and elements. This has been a very simple post to show how to achieve something specific. I shall be writing a follow-up on Zend Form Decorators, explaining what they are, the Mandatory Decorators, the Common Decorators, the Common Options and a LOT of examples to demonstrate how flexible and versatile Zend_Form is.