- <?php
- require_once("HTML/QuickForm/Wizard/Wizard.php");
-
-
- class PageSecond extends HTML_QuickForm_Page
- {
- function buildForm()
- {
- $this->_formBuilt = true;
-
- $this->addElement('header', null, 'Wizard page 2 of 3');
-
- $name['last'] = &$this->createElement('text', 'last', null, array('size' => 30));
- $name['first'] = &$this->createElement('text', 'first', null, array('size' => 20));
- $this->addGroup($name, 'name', 'Name (last, first):', ', ');
-
- $prevnext[] =& $this->createElement('submit', $this->getButtonName('back'), '<< Back');
- $prevnext[] =& $this->createElement('submit', $this->getButtonName('next'), 'Next >>');
- $this->addGroup($prevnext, null, '', ' ', false);
-
- $this->addGroupRule('name', array('last' => array(array('Last name is required', 'required'))));
-
- $this->setDefaultAction('next');
- }
- }
-
-
- class PageSecondBis extends HTML_QuickForm_Page
- {
- function buildForm()
- {
- $this->_formBuilt = true;
-
- $this->addElement('header', null, 'Wizard page 2 bis of 3');
-
- $this->addElement('textarea', 'why', 'Why are you not sure?:', array('rows' => 5, 'cols' => 40));
-
- $prevnext[] =& $this->createElement('submit', $this->getButtonName('back'), '<< Back');
- $prevnext[] =& $this->createElement('submit', $this->getButtonName('next'), 'Next >>');
- $this->addGroup($prevnext, null, '', ' ', false);
-
- $this->addRule('why', 'Say something!', 'required');
-
- $this->setDefaultAction('next');
- }
- }
-
-
- class PageThird extends HTML_QuickForm_Page
- {
- function buildForm()
- {
- $this->_formBuilt = true;
-
- $this->addElement('header', null, 'Wizard page 3 of 3');
-
- $this->addElement('textarea', 'itxaTest', 'Parting words:', array('rows' => 5, 'cols' => 40));
-
- $prevnext[] =& $this->createElement('submit', $this->getButtonName('back'), '<< Back');
- $prevnext[] =& $this->createElement('submit', $this->getButtonName('next'), 'Finish');
- $this->addGroup($prevnext, null, '', ' ', false);
-
- $this->addRule('itxaTest', 'Say something!', 'required');
-
- $this->setDefaultAction('next');
- }
- }
-
-
-
- class ActionProcess extends HTML_QuickForm_Action
- {
- function perform(&$page, $actionName)
- {
- echo "Submit successful!<br>\n<pre>\n";
- var_dump($page->controller->exportValues());
- echo "\n</pre>\n";
-
- $page->controller->reset();
- }
- }
-
-
- function myInputProducer(&$data)
- {
- if ($data['values']['A']['iradYesNo'] == 'Y') {
- return 'sure';
- }
-
- return '';
- }
-
-
-
- // Start the session, form-page values will be kept there
- session_start();
-
- $wizard = new HTML_QuickForm_Wizard($_SERVER['PHP_SELF'], true);
-
- $wizard->fromXML('example.xml', true);
-
- $wizard->addAction('process', new ActionProcess());
- $wizard->setInputProducer('myInputProducer');
-
- if (isset($_REQUEST[reset])) $wizard->reset();
- $data =& $wizard->container(isset($_REQUEST['new']));
-
- $wizard->run();
- ?>