QuickForm controller custome Next action
| From: | Arnaud Limbourg | Date: | Fri, 26 Sep 2003 15:33:42 +0000 |
| Subject: | QuickForm controller custome Next action | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-8066@lists.php.net to get a copy of this message | ||
Hi,
I wrote a custom action for a next button.
It extends from Action_Next and checks for a certain condition. If this condition is true it then jumps to a given page.
I start on page one and click next (my custom conditionnal next) it goes on to page 2 (instead of page 3). If i click previous i go back on page one. Then i press next an it jumps to page 3.
I added some var_dump and i see that the first time next has the right value (page3).
Any idea what might be causing this ?
Here is the incriminated action if it helps.
class ActionConditionalNext extends HTML_QuickForm_Action_Next
{
function perform(&$page, $actionName)
{
// save the form values and validation status to the session
$page->isFormBuilt() or $page->buildForm();
$pageName = $page->getAttribute('name');
$data =& $page->controller->container();
$data['values'][$pageName] = $page->exportValues();
$data['valid'][$pageName] = $page->validate();
// Modal form and page is invalid: don't go further
if ($page->controller->isModal() && !$data['valid'][$pageName]) {
return $page->handle('display');
}
$nextName = $page->controller->getNextName($pageName);
switch ($data['values'][$pageName]['field']) {
case 'test':
$nextName = 'page3';
break;
}
$next =& $page->controller->getPage($nextName);
$next->handle('jump');
}
}
Arnaud.