<?php require_once("../Wizard.php");
class PageSecond extends HTML_QuickForm_Page { function buildForm() { $this->_formBuilt = true;
$this->addElement('header', null, 'Wizard page 2 of 3 (B)');
$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 (C)');
$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 (D)');
$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) { $input = array();
if ($data['values']['A']['iradYesNo'] == 'Y') { array_push($input, 'sure'); }
return empty($input) ? '' : $input; }
// Start the session, form-page values will be kept there session_start();
$wizard = new HTML_QuickForm_Wizard($_SERVER['PHP_SELF'], true);
//include_once("fsm.php"); //$wizard->setFSM($fsm); $wizard->fromXML('test.xml', true); print "<pre>"; print_r($wizard->getFSM()); print "</pre>";
$wizard->addAction('process', new ActionProcess()); $wizard->setInputProducer('myInputProducer');
if (isset($_REQUEST[reset])) $wizard->reset(); $data =& $wizard->container(isset($_REQUEST['new']));
$wizard->run(); ?>
|