Rendering a form object is completely optional -- you do not need to use
Zend_Form's render() methods at all. However, if you do,
decorators are used to render the various form objects.
An arbitrary number of decorators may be attached to each item (elements, display groups, sub forms, or the form object itself); however, only one decorator of a given type may be attached to each item. Decorators are called in the order they are registered. Depending on the decorator, it may replace the content passed to it, or append or prepend the content.
Object state is set via configuration options passed to the constructor
or the decorator's
setOptions() method. When creating
decorators via an item's
addDecorator() or related methods,
options may be passed as an argument to the method. These can be used to
specify placement, a separator to use between passed in content and
newly generated content, and whatever options the decorator supports.
Before each decorator's
render() method is called, the
current item is set in the decorator using
giving the decorator awareness of the item being rendered. This allows
you to create decorators that only render specific portions of the item
-- such as the label, the value, error messages, etc. By stringing
together several decorators that render specific element segments, you
can build complex markup representing the entire item.