HTML_QuickForm_Wizard
[ class tree: HTML_QuickForm_Wizard ] [ index: HTML_QuickForm_Wizard ] [ all elements ]

Source for file example.php

Documentation is available at example.php

  1. <?php
  2. require_once("HTML/QuickForm/Wizard/Wizard.php");
  3.  
  4.  
  5. class PageSecond extends HTML_QuickForm_Page
  6. {
  7. function buildForm()
  8. {
  9. $this->_formBuilt = true;
  10.  
  11. $this->addElement('header', null, 'Wizard page 2 of 3');
  12.  
  13. $name['last'] = &$this->createElement('text', 'last', null, array('size' => 30));
  14. $name['first'] = &$this->createElement('text', 'first', null, array('size' => 20));
  15. $this->addGroup($name, 'name', 'Name (last, first):', ',&nbsp;');
  16.  
  17. $prevnext[] =& $this->createElement('submit', $this->getButtonName('back'), '<< Back');
  18. $prevnext[] =& $this->createElement('submit', $this->getButtonName('next'), 'Next >>');
  19. $this->addGroup($prevnext, null, '', '&nbsp;', false);
  20.  
  21. $this->addGroupRule('name', array('last' => array(array('Last name is required', 'required'))));
  22.  
  23. $this->setDefaultAction('next');
  24. }
  25. }
  26.  
  27.  
  28. class PageSecondBis extends HTML_QuickForm_Page
  29. {
  30. function buildForm()
  31. {
  32. $this->_formBuilt = true;
  33.  
  34. $this->addElement('header', null, 'Wizard page 2 bis of 3');
  35.  
  36. $this->addElement('textarea', 'why', 'Why are you not sure?:', array('rows' => 5, 'cols' => 40));
  37.  
  38. $prevnext[] =& $this->createElement('submit', $this->getButtonName('back'), '<< Back');
  39. $prevnext[] =& $this->createElement('submit', $this->getButtonName('next'), 'Next >>');
  40. $this->addGroup($prevnext, null, '', '&nbsp;', false);
  41.  
  42. $this->addRule('why', 'Say something!', 'required');
  43.  
  44. $this->setDefaultAction('next');
  45. }
  46. }
  47.  
  48.  
  49. class PageThird extends HTML_QuickForm_Page
  50. {
  51. function buildForm()
  52. {
  53. $this->_formBuilt = true;
  54.  
  55. $this->addElement('header', null, 'Wizard page 3 of 3');
  56.  
  57. $this->addElement('textarea', 'itxaTest', 'Parting words:', array('rows' => 5, 'cols' => 40));
  58.  
  59. $prevnext[] =& $this->createElement('submit', $this->getButtonName('back'), '<< Back');
  60. $prevnext[] =& $this->createElement('submit', $this->getButtonName('next'), 'Finish');
  61. $this->addGroup($prevnext, null, '', '&nbsp;', false);
  62.  
  63. $this->addRule('itxaTest', 'Say something!', 'required');
  64.  
  65. $this->setDefaultAction('next');
  66. }
  67. }
  68.  
  69.  
  70.  
  71. class ActionProcess extends HTML_QuickForm_Action
  72. {
  73. function perform(&$page, $actionName)
  74. {
  75. echo "Submit successful!<br>\n<pre>\n";
  76. var_dump($page->controller->exportValues());
  77. echo "\n</pre>\n";
  78.  
  79. $page->controller->reset();
  80. }
  81. }
  82.  
  83.  
  84. function myInputProducer(&$data)
  85. {
  86. if ($data['values']['A']['iradYesNo'] == 'Y') {
  87. return 'sure';
  88. }
  89.  
  90. return '';
  91. }
  92.  
  93.  
  94.  
  95. // Start the session, form-page values will be kept there
  96. session_start();
  97.  
  98. $wizard = new HTML_QuickForm_Wizard($_SERVER['PHP_SELF'], true);
  99.  
  100. $wizard->fromXML('example.xml', true);
  101.  
  102. $wizard->addAction('process', new ActionProcess());
  103. $wizard->setInputProducer('myInputProducer');
  104.  
  105. if (isset($_REQUEST[reset])) $wizard->reset();
  106. $data =& $wizard->container(isset($_REQUEST['new']));
  107.  
  108. $wizard->run();
  109. ?>

Documentation generated on Thu, 19 Apr 2007 08:13:25 +0200 by phpDocumentor 1.3.0RC3