Re: QFC validation

From: Date: Sat, 25 Oct 2003 08:57:00 +0000
Subject: Re: QFC validation
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-8574@lists.php.net to get a copy of this message
Hi! Daniel Kopp wrote:
Just found out that the forms are only validated before the "process" Action. How can I get validation for more than one Button? How can I call it myself? I want something like the "tabbed.php" example but I want it to validate the Form no matter which button is pressed.
What is wrong with creating a wizard for this and maybe adding some more buttons for easier navigation?
And - how come in the Form it is: $this->getButtonName('submit') Whereas the Action that is called is 'process'? Usually - when I want to bind an Action to a Button I have to use the same name. Is 'process' the default Action which is called if the named Action (in this case 'submit') does not exist? It also seems that I do not manage to get a Button in a group (for use with renderers) connected with the process Action.
About the 'process' action: it should NOT be bound to buttons, it is automatically called by default 'submit' and 'next' handlers when the form is finally validated. I thought I described this in the docs but unfortunately it does not seem the case. :[
Finally Renderers: Is it a good idea (unfortunately I forgot where I got this) to put the whole renderer in the display class:
Yes, this *is* in the docs: http://pear.php.net/manual/en/package.html.html-quickform-controller.html-quickform-action-display-summary.php You should subclass HQ_Action_Display and put all the renderer stuff into its _renderForm() method.
$renderer =& $page->defaultRenderer(); $tpl =& new HTML_Template_Sigma('Templates/'); $tpl->loadTemplateFile('file.html'); $renderer =& new HTML_QuickForm_Renderer_ITStatic($tpl); $renderer->setRequiredTemplate('{label}<font color="red" size="1">*</font>'); $renderer->setErrorTemplate('<font color="red">{error}</font><br />{html}'); $GLOBALS['_HTML_QuickForm_default_renderer'] = $renderer; $page->accept($renderer); $tpl->show();
The code looks strange. If you are using the custom renderer, you don't need to touch the default renderer at all. Thus $renderer =& $page->defaultRenderer(); $GLOBALS['_HTML_QuickForm_default_renderer'] = $renderer; should be thrown out, all the other stuff can go to the _renderForm() method.
There are just so many details that nobody tells you ... I would really appreciate a couple of bigger examples ... I feel quite stupid to have to ask everything here ...
Well, QFC is a complex package and it also requires a great deal of familiarity with QF itself. Don't feel stupid about these questions, as the answers to them will eventually find their way into the docs.

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