QFC, modal forms and the back button

From: Date: Mon, 13 Sep 2004 14:25:14 +0000
Subject: QFC, modal forms and the back button
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-14516@lists.php.net to get a copy of this message
For some reason I must clear the QFC container at the end of a successful processing. The problem: this causes trouble when the user hits the back button (an action that has no logic in this case, but which can happen) Consider this simple test case: ------------------------------------------------------------ session_start(); class Page1 extends HTML_QuickForm_Page { function buildForm() { $this->_formBuilt = true; $this->addElement('header', null, 'Wizard page 1 of 2'); $this->addElement('text', 'first_name', 'First name' ) ; $this->addElement('text', 'last_name', 'Last name' ) ; $this->addElement('submit', $this->getButtonName('next'), 'Next >>'); } } class Page2 extends HTML_QuickForm_Page { function buildForm() { $this->_formBuilt = true; $this->addElement('header', null, 'Wizard page 2 of 2'); $text = sprintf( "Is %s %s your real name?", $GLOBALS['container']['values']['page1']['first_name'], $GLOBALS['container']['values']['page1']['last_name'] ) ; $this->addElement('static', '', '', $text); $this->addElement('submit', $this->getButtonName('next'), 'Finish >>'); } } class ActionProcess extends HTML_QuickForm_Action { function perform(&$page, $actionName) { echo "Success"; unset( $_SESSION['_Wizard_container'] ) ; } } $wizard =& new HTML_QuickForm_Controller('Wizard', true); $wizard->addPage(new Page1('page1')); $wizard->addPage(new Page2('page2')); $container =& $wizard->container() ; $wizard->addAction('process', new ActionProcess()); $wizard->run(); ------------------------------------------------------------ After the user completes the form and hits the back button, the page called is: http://localhost/wizard.php?_qf_page2_display=true which shows an error message (because the container has been cleared, the variables $GLOBALS['container']['values']['page1']['first_name'], etc. do not exist any more) I would have expected - in the case of a modal form- that such a call be redirected to the page1 display form (because the container does not contain a ['valid']['page1'] = 1, so it should not show the page 2. What did I get wrong? Thanks Ignatius

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