Comunitatea PHP Romania
 

 
Introduction - renderers

Introduction - renderers

Introduction - renderers -- How to output the form

What are renderers?

Before release 3.0, form outputting logic was implemented as methods of HTML_QuickForm class. This led to two problems:

  1. Bloat of the said class (80+ methods!)

  2. 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:

  1. Code for some particular output method is loaded only when the method is used.

  2. It is much easier to add new output method.

There are 8 renderers available since release 3.1.1, of which 2 are based on pre-3.0 code and 6 are new. The following template engines are directly suported: Smarty, HTML_Template_Sigma, HTML_Template_IT, HTML_Template_Flexy.

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();
?>
Actual methods for customization and doing the output will of course depend on renderer type.

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.

Ultimele discutii in forum RSS Forum

Ultimele articole Ultimele articole

Top membri

Pirahna Pirahna
la birou
carco carco
Bucuresti
Birkoff Birkoff
Bucuresti
mihaitha mihaitha
Sibiu
Mascka Mascka
Braila
gabysolomon gabysolomon
Bacau
whooper whooper
Toronto ON
raul_ raul_
dechim dechim
Drobeta Turnu Severin
Amenthes Amenthes

Newsletter


Email:
 inscriere
 renuntare
 
 Arhiva newsletter

Parteneriat

Copyright © 2001-2009 PHP Romania Add PHPRomania to Google Add PHPRomania to Del.icio.us Add PHPRomania to Stumbleupon Add PHPRomania to Yahoo! Add PHPRomania to Digg Add PHPRomania to Blink Posicionamiento | Mortgage Calculator | Credit Cards | Internet Advertising | Debt Consolidation
Ads: Partener Way2Web Nework: gazduire web | inregistrare domenii | web design | imobiliare | web hosting
Powered by Simplis