QuickForm - Arrgg!
| From: | Wade Hovind | Date: | Thu, 10 Apr 2003 18:57:14 +0000 |
| Subject: | QuickForm - Arrgg! | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-4784@lists.php.net to get a copy of this message | ||
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 variables
since 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 lower
level 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>