Re: QuickForm - Arrgg!
| From: | Demian Turner | Date: | Thu, 10 Apr 2003 21:00:52 +0000 |
| Subject: | Re: QuickForm - Arrgg! | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-4787@lists.php.net to get a copy of this message | ||
I just got something similar working over the last few days. perhaps you need to simplify your code, I'm using something like this and it works as expected:
// get current stage
$iCurrentStage = Session::get('SESS_CURRENT_STAGE')
// build form name
$sFormName = 'RegForm_' . $iCurrentStage;
require_once PSG_MOD_DIR . '/UserMgr/' . $sFormName . '.php';
// instantiate Quickform in an object wrapper
$oForm = & new $sFormName('add');
$output->form = $oForm->init();
// if submitted, validate
if($this->submitted == 'Save')
$validated = $output->form->validate();// if validated, confirm if($validated) {
// remove submit buttons, replace with confirm
$output->form->freeze();
}
// if confirmed, write to DB
if($this->submitted == 'Confirm')
// code to write to DB// increment reg stage $this->iRegStage ++; Session::set('SESSION_REG_STAGE', $this->iRegStage); hth, Demian Wade Hovind wrote:
I'm attempting to write a series of forms to collect a whole bunch of information. Here's the 'plan' Set a session variable 'step' and intialize it to one. In a file do a switch on the value of the session variable and include the correct file form1.php, form2.php etc. dsp_autoQuote - simplified contents: print "<pre>"; print '$_SESSION[step]: ' . $_SESSION['step'] . "\n"; print "</pre>"; switch($_SESSION['step']) { case "1": include("dsp_autoQuote1.php"); break; case "2": include("dsp_autoQuote2.php"); break; case "3": include("dsp_autoQuote3.php"); break; case "4": include("dsp_autoQuote2.php"); break; default: print 'I received step <b>' . $_SESSION['step'] . '</b> that dsp_autoQuote.php does not have a handler for.'; break; } In each file declare a QuickForm and at the bottom have the conditional if($form->validate()) {//do some stuff to save the values submitted off to session variablessince they won't be//processed until the final step.//update the session var and call the file with the switch in it again... the switch will then include//the needed file. I've tried this with a direct include of the lowerlevel file but that doesn't work//either. $_SESSION['step']++; include "dsp_autoQuote.php";} else {$form->display();} I'm TOTALLY confused by what's happening. First form comes up fine. $_SESSION['step'] is at 1 and the form displays without any validation errors. When I hit the submit on this form and the validation passes ($form->validate() is true) then things start to go haywire. $_SESSION['step'] displays as 1 but the the switch statement includes the proper file (the second) EXCEPT the validations have failed once. There is the error message on the fields that require validation. If I hit the back button then everything is as is should be on the submit. I realize I'm missing something here and probably having a "brain fart". <whine>HELP</whine>