Re: HTML_QuickForm_element::accept()

From: Date: Sat, 15 Sep 2007 11:31:42 +0000
Subject: Re: HTML_QuickForm_element::accept()
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-27936@lists.php.net to get a copy of this message
Hi, Christoph Boget wrote:
I'm not sure I understand why you would pass a renderer to an element. Is it just to define a renderer (and possibly a template) for that individual element? Would /should the template be defined as part of the attributes that get passed to the contructor? And both the renderer and template would/should be used in the toHTML() method?
You don't usually pass the renderer to the element yourself, you set it up (by e.g. providing necessary templates) then pass to HTML_QuickForm's accept() method. The method takes care of passing the renderer to each element and the renderer takes care of aggregating the elements' HTML and adding that to the templates. toHtml() methods are there just to output the element itself, not "element as a part of the form". There are some elements that do use the Default renderer in their toHtml() method, but that's basically done to prevent repeating the code already present in their or their parent's accept() method (e.g. group). So yes, you can use a renderer in toHtml() method and you can set the template for your element if it is complex enough to need a template. But bear in mind that toHtml() needs to just output the element itself or there will be trouble with integrating your element into the form's template.

« previous php.pear.general (#27936) next »