PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Rendering Individual Decorators

Since decorators can target distinct metadata of the element or form they decorate, it's often useful to render one individual decorator at a time. This behavior is possible via method overloading in each major form class type (forms, sub form, display group, element).

To do so, simply call render[DecoratorName](), where "[DecoratorName]" is the "short name" of your decorator; optionally, you can pass in content you want decorated. For example:

<?php
// render just the element label decorator:
echo $element->renderLabel();

// render just the display group fieldset, with some content:
echo $group->renderFieldset('fieldset content');

// render just the form HTML tag, with some content:
echo $form->renderHtmlTag('wrap this content');

If the decorator does not exist, an exception is raised.

This can be useful particularly when rendering a form with the ViewScript decorator; each element can use its attached decorators to generate content, but with fine-grained control.

Zend Framework