Before release 3.0, form outputting logic was implemented as methods of HTML_QuickForm class. This led to two problems:
Bloat of the said class (80+ methods!)
Difficulties in adding new output logic (i.e. using template engines)
In release 3.0, new system was implemented. The form output logic is now contained in classes that extend HTML_QuickForm_Renderer, their behaviour is based on Visitor design pattern from the classic "Design Patterns" book. This gives the following advantages:
Code for some particular output method is loaded only when the method is used.
It is much easier to add new output method.
The main steps of using any available renderer are quite similar:
<?php // include the renderer class require_once 'HTML/QuickForm/Renderer/FooBar.php'; // instantiate the renderer $renderer =& new HTML_QuickForm_Renderer_FooBar($options); // do some customization $renderer->adjustSomething('element1', '...'); // ... $renderer->adjustSomething('elementN', '...'); // process the form $form->accept($renderer); // output the results $renderer->toFooBar(); ?> |
Concerning usage examples: Usage examples provided in the manual are pretty basic. More complex examples for Default renderer can be found in docs/ directory, for all other renderers - in docs/renderers/ directory of HTML_QuickForm.