Re: Pb in Use QuickForm and HTML_page with a renderer
| From: | Jean-Charles Gibier | Date: | Fri, 20 Feb 2004 10:47:38 +0000 |
| Subject: | Re: Pb in Use QuickForm and HTML_page with a renderer | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-10816@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Alexey Borzov" <borz_off@cs.msu.su>
To: "Jean-Charles Gibier" <j-c.gibier@wanadoo.fr>
Cc: <pear-general@lists.php.net>
Sent: Friday, February 20, 2004 7:45 AM
Subject: Re: [PEAR] Pb in Use QuickForm and HTML_page with a renderer
: Hi!
:
: Jean-Charles Gibier wrote:
: > 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.
:
: The problem is unrelated to HTML_Page in any way. You obviously didn't
bother to
: isolate it.
:
: Here you actually render the form *twice*. First with your own renderer
when you
: call accept(), then with the default renderer when you call tohtml().
Hmm, I'm sorry. I hope that I did not upset you.
My purpose is not to give out of box this code but to understand it.
[...]
: That's because you need to call validate() before accept(). It is
validate()
: that sets the form's error messages.
This was precisely the explanation that I need :-)
According to your advices and this of Bertrand Mansion this code seems to
work.
But if you are any comment ...
------------------8<-------------------
$form = new HTML_QuickForm('SONDAGE', 'post');
$renderer =& new Phpaie_Renderer_Default ();
[...]
// feed the form content
$form->addElement( ...
[...]
if(($form->validate() == 0)) {
//personal stuff that doesn't really matter
$this->invalidateStatus();
}
$form->accept($renderer);
$page->addBodyContent($renderer->tohtml());
------------------8<-------------------