Re: QFC and Templates
| From: | Bertrand Mansion | Date: | Mon, 01 Mar 2004 19:21:22 +0000 |
| Subject: | Re: QFC and Templates | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11043@lists.php.net to get a copy of this message | ||
<jsbiff@weldingengineering.com> wrote :
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
> ~ I want to use QuickForm_Controller to build a multi-page 'wizard'
> type form. I am developing a separate static IT template for each page,
> and what I can't figure out from the documentation or examples is, how
> can I associate a different template with each page. That is, in order
> to use a template render, I think I subclass
> HTML_QuickForm_Action_Display and provide an implementation of the
> method _renderForm(). Somewhere in _renderForm(), I think, I need to
> somehow figure out what page I'm trying to render, and load the correct
> template file.
>
> For example:
>
> class PageOne extends HTML_QuickForm_Page
> {
> ~ function buildForm()
> ~ {
> ~ $this->_formBuilt = true;
>
> //stuff for creating the first page of the wizard.
> ~ }
> }
>
> class PageTwo extends HTML_QuickForm_Page
> {
> ~ function buildForm()
> ~ {
> ~ $this->_formBuilt = true;
>
> //stuff for creating the second page of the wizard.
> ~ }
> }
>
> class ActionDisplay extends HTML_QuickForm_Action_Display
> {
> ~ function _renderForm(&$page)
> ~ {
> ~ require_once 'HTML/QuickForm/Renderer/ITStatic.php';
>
> ~ $tpl =& new HTML_Template_IT('./templates');
>
> //somehow figure out what page I'm processing and load the
> //appropriate template file.
>
> //Below, someMethod() lets me figure out what page I'm actually
> //processing, hopefully.
>
> if ($page->someMethod() == 'page1')
> ~ {
> $tpl->loadTemplateFile('page1.html');
> }
>
> else if ($page->someMethod() == 'page2')
> ~ {
> $tpl->loadTemplateFile('page2.html');
> }
>
>
> ~ $renderer =& new HTML_QuickForm_Renderer_ITStatic($tpl);
>
> ~ $page->accept($renderer);
> ~ $tpl->show();
> ~ }
> }
$pageName = $page->getAttribute('name') should do.
Bertrand Mansion
Mamasam