Re: Pb in Use QuickForm and HTML_page with a renderer
| From: | Bertrand Mansion | Date: | Thu, 19 Feb 2004 22:36:44 +0000 |
| Subject: | Re: Pb in Use QuickForm and HTML_page with a renderer | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-10807@lists.php.net to get a copy of this message | ||
<j-c.gibier@wanadoo.fr> wrote :
> Hello,
> I have a little pb with the simultaneous use of packages QF and HTML (both
> in version 1.1) when I use my own renderer.
> My problem is, if I have :
> --------------8< --------------
> $page = new HTML_Page(... ));
> if (!empty($this->headerBuffer)) {
> $page->addBodyContent( " nananinnanana ...");
> }
> ...
> $form = new HTML_QuickForm('SONDAGE', 'post');
> $renderer =& new Phpaie_Renderer_Default ();
> $form->accept ($renderer);
> $form->validate();
> $page->addBodyContent($form->tohtml());
> ...
> --------------8< --------------
> -> The renderer stays as the default one, and i can't realize my features..
>
> And if I have the following :
> --------------8< --------------
> $page = new HTML_Page(... ));
> if (!empty($this->headerBuffer)) {
> $page->addBodyContent( " nananinnanana ...");
> }
>
> $form = new HTML_QuickForm('SONDAGE', 'post');
> $renderer =& new Phpaie_Renderer_Default ();
> $form->accept ($renderer);
> $form->validate();
> $page->addBodyContent($renderer->tohtml());
> // consider $renderer->tohtml() instead of $form->tohtml()
> --------------8< --------------
>
> I've got my good renderer feature, when it is validated but the error
> messages does'nt display.
>
> I have found a solution but thats seems quite dirty to me (because I dislike
> use globals) :
> --------------8< --------------
> $GLOBALS['_HTML_QuickForm_default_renderer'] = $renderer =& new
> Phpaie_Renderer_Default ();
> --------------8< --------------
>
> But there is certainly another solution, or maybe this pb is fixed in the
> lastest version ?
There might be something wrong in the way your renderer handles errors.
You have to use $renderer->toHtml() if you want your renderer to be used
instead of the default one. You can look at the way the default renderer or
the IT renderer handle errors.
Bertrand Mansion
Mamasam