HTML_QuickForm_Controller: improved default behaviour
| From: | Charly Pache | Date: | Mon, 16 Feb 2009 16:15:03 +0000 |
| Subject: | HTML_QuickForm_Controller: improved default behaviour | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-29693@lists.php.net to get a copy of this message | ||
Issue:
The current version of class HTML_QuickForm_Page does not allow to have a
wizard on a page that has already query parameters in the URL (!?), ie
'http://localhost/index.php?goto=wizzard_name'
cos the attribute 'action' of
the form is set to '' and instead of the second step, you'll be redirected
to 'http://localhost/index.php'.
Solution:
I suggest two actions:
1-- Change the constructor of HTML_QuickForm_Page, putting
$_SERVER['REQUEST_URI'] instead of '' as the third attribute of the
HTML_QuickForm constructor:
function HTML_QuickForm_Page($formName, $method = 'post', $target = '',
$attributes = null)
{
$this->HTML_QuickForm($formName, $method, $_SERVER['REQUEST_URI'],
$target, $attributes);
}
2-- Change the example wizard.php, adding this line to each call of each
function buildForm():
$this->setAttribute('action', '?action=wizzard_name');
For example for the first Page class:
"
class PageFirst extends HTML_QuickForm_Page
{
function buildForm()
{
$this->_formBuilt = true;
$this->setAttribute('action', '?goto=wizzard_name');// !!!NEW!!!
$this->addElement('header', null, 'Wizard page 1 of 3');
http://www.nabble.com/file/p22040242/example_wizard.php
example_wizard.php
$radio[] = &$this->createElement('radio', null, null, 'Yes',
'Y');
$radio[] = &$this->createElement('radio', null, null, 'No',
'N');
$this->addGroup($radio, 'iradYesNo', 'Are you absolutely sure?');
$this->addElement('submit', $this->getButtonName('next'),
'Next >>');
$this->addRule('iradYesNo', 'Check Yes or No', 'required');
$this->setDefaultAction('next');
}
}
"
Hope this will help others.
--
View this message in context: http://www.nabble.com/HTML_QuickForm_Controller%3A-improved-default-behaviour-tp22040242p22040242.html
Sent from the Pear - General mailing list archive at Nabble.com.