Problem with HTML_QuickForms_Controller making a custom action
| From: | Jachin Rupe | Date: | Mon, 21 Jun 2004 13:45:59 +0000 |
| Subject: | Problem with HTML_QuickForms_Controller making a custom action | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-13224@lists.php.net to get a copy of this message | ||
hi there
I am trying to make a very simple confirm form. It's very simple should work. So simple in fact I though it might be a php problem but I have tried it on a couple different version of php with no luck.
When you run it the ActionProcess->perform gets called when you hit the 'yes' button. However when you hit the 'no' button the ActionCanel->perform does not seem to be called.
any help would very appreciated
thank you
-jachin
<?php
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Controller.php';
require_once 'HTML/QuickForm/Action.php';
require_once 'HTML/QuickForm/Action/Display.php';
class ConfirmPage extends HTML_QuickForm_Page
{
function buildForm()
{
$this->_formBuilt = true;
$this->addElement('header', '', 'Confirm');
$this->addElement('html', "<tr><td>Are you sure?</td></tr>");
$this->addElement('submit', $this->getButtonName('process'), 'yes');
$this->addElement('submit', $this->getButtonName('cancel'), 'no');
$this->setDefaultAction('cancel');
}
}
class ActionCancel extends HTML_QuickForm_Action
{
function preform(&$page, $actionName)
{
echo 'It is NOT done.';
}
}
class ActionProcess extends HTML_QuickForm_Action
{
function perform(&$page, $actionName)
{
echo 'It is done.';
}
}
$controller =& new HTML_QuickForm_Controller('confirm_test');
$page =& new ConfirmPage('confirm_page');
$controller->addPage($page);
$controller->addAction('cancel', new ActionCancel());
$controller->addAction('process', new ActionProcess());
$controller->run();
?>