Re: Re: [PEAR] HTML_QuickForm_Controller -> is there an easy way to kind of freeze() the forms

From: Date: Tue, 07 Dec 2004 21:48:52 +0000
Subject: Re: Re: [PEAR] HTML_QuickForm_Controller -> is there an easy way to kind of freeze() the forms
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16093@lists.php.net to get a copy of this message
Example -- function Page1(&$form) { //..define elements (no buttons or rules) } function Page2(&$form) { //..define elements (no buttons or rules) } class PageFirst extends HTML_QuickForm_Page { function buildForm() { $this->_formBuilt = true; Page1($this); //buttons and rules $this->setDefaultAction('next'); } } class PageSecond extends HTML_QuickForm_Page { function buildForm() { $this->_formBuilt = true; Page2($this); //buttons and rules $this->setDefaultAction('next'); } } class PageThird extends HTML_QuickForm_Page { function buildForm() { $this->_formBuilt = true; $data =& $this->controller->container(); $values = array_merge($data['values']['page1'], $data['values']['page2']); Page1($this); Page2($this); // buttons $this->freeze(); $this->loadValues($values); $this->setDefaultAction('next'); } } $wizard =& new HTML_QuickForm_Controller('Wizard'); $wizard->addPage(new PageFirst('page1')); $wizard->addPage(new PageSecond('page2')); $wizard->addPage(new PageThird('page3')); Peace, Denny Free courses: astral projection, meditation, gnosis, alchemy -- http://mysticweb.org robert wrote: > Hi there! > > The problem: > I have to create many complex, wizard-like forms spread on multiple > pages, so HTML_QuickForm and HTML_QuickForm_Controller seemed to be the > right solution for me. > The last step of some forms should be a kind of confirm page, where all > the data the user entered is displayed. In HTML_QuickForm I would do > this with $myForm->freeze(), but with HTML_QuickForm_Controller this > does not seem to work. > > My approach was based on the regWizard example in the documentation: > build the first two pages and copy the buildForm code in the buildForm > of the confirmation Page and then set the defaults for the confirmation > page from the $_SESSION array. > The first time the confirmation page is displayed this will work, but if > I go back and change some data it ill not update the defaults. > Any hints appreciated. I wouldn't use freeze() here. I didn't read your code but this is how I would do it: The last form would be made of static elements with a prefix in their names. For example: 'stat_name' would show the value of the element 'name' filled in a \ previous step. In order to fill the static elements with values, I'd create Next/Back actions and \ check which is the page that was requested, and fill the static default values \ accordingly using controller->applyDefaults(). There might be an example of this \ process in the 'upload' example. Bertrand Mansion Mamasam

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