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

Source for file wizard.php

Documentation is available at wizard.php

  1. <?php
  2. /**
  3.  * Example 2 for HTML_QuickForm_Controller: Wizard
  4.  *
  5.  * @version SVN: $Id: wizard.php 289084 2009-10-02 06:53:09Z avb $
  6.  * @author  Alexey Borzov <avb@php.net>
  7.  * @ignore
  8.  */
  9.  
  10. require_once 'HTML/QuickForm/Controller.php';
  11.  
  12. // Load some default action handlers
  13. require_once 'HTML/QuickForm/Action/Next.php';
  14. require_once 'HTML/QuickForm/Action/Back.php';
  15. require_once 'HTML/QuickForm/Action/Jump.php';
  16. require_once 'HTML/QuickForm/Action/Display.php';
  17.  
  18. // Start the session, form-page values will be kept there
  19.  
  20. {
  21.     function buildForm()
  22.     {
  23.         $this->_formBuilt = true;
  24.  
  25.         $this->addElement('header',     null'Wizard page 1 of 3');
  26.  
  27.         $radio[&$this->createElement('radio'nullnull'Yes''Y');
  28.         $radio[&$this->createElement('radio'nullnull'No''N');
  29.         $this->addGroup($radio'iradYesNo''Are you absolutely sure?');
  30.  
  31.         $this->addElement('submit',     $this->getButtonName('next')'Next >>');
  32.  
  33.         $this->addRule('iradYesNo''Check Yes or No''required');
  34.  
  35.         $this->setDefaultAction('next');
  36.     }
  37. }
  38.  
  39. {
  40.     function buildForm()
  41.     {
  42.         $this->_formBuilt = true;
  43.  
  44.         $this->addElement('header',     null'Wizard page 2 of 3');
  45.  
  46.         $name['last']  &$this->createElement('text''last'nullarray('size' => 30));
  47.         $name['first'&$this->createElement('text''first'nullarray('size' => 20));
  48.         $this->addGroup($name'name''Name (last, first):'',&nbsp;');
  49.  
  50.         $prevnext[=$this->createElement('submit',   $this->getButtonName('back')'<< Back');
  51.         $prevnext[=$this->createElement('submit',   $this->getButtonName('next')'Next >>');
  52.         $this->addGroup($prevnextnull'''&nbsp;'false);
  53.  
  54.         $this->addGroupRule('name'array('last' => array(array('Last name is required''required'))));
  55.  
  56.         $this->setDefaultAction('next');
  57.     }
  58. }
  59.  
  60. {
  61.     function buildForm()
  62.     {
  63.         $this->_formBuilt = true;
  64.  
  65.         $this->addElement('header',     null'Wizard page 3 of 3');
  66.  
  67.         $this->addElement('textarea',   'itxaTest''Parting words:'array('rows' => 5'cols' => 40));
  68.  
  69.         $prevnext[=$this->createElement('submit',   $this->getButtonName('back')'<< Back');
  70.         $prevnext[=$this->createElement('submit',   $this->getButtonName('next')'Finish');
  71.         $this->addGroup($prevnextnull'''&nbsp;'false);
  72.  
  73.         $this->addRule('itxaTest''Say something!''required');
  74.  
  75.         $this->setDefaultAction('next');
  76.     }
  77. }
  78.  
  79.  
  80.  
  81. {
  82.     function perform(&$page$actionName)
  83.     {
  84.         echo "Submit successful!<br>\n<pre>\n";
  85.         var_dump($page->controller->exportValues());
  86.         echo "\n</pre>\n";
  87.     }
  88. }
  89.  
  90. $wizard =new HTML_QuickForm_Controller('Wizard');
  91. $wizard->addPage(new PageFirst('page1'));
  92. $wizard->addPage(new PageSecond('page2'));
  93. $wizard->addPage(new PageThird('page3'));
  94.  
  95. // We actually add these handlers here for the sake of example
  96. // They can be automatically loaded and added by the controller
  97. $wizard->addAction('display'new HTML_QuickForm_Action_Display());
  98. $wizard->addAction('next'new HTML_QuickForm_Action_Next());
  99. $wizard->addAction('back'new HTML_QuickForm_Action_Back());
  100. $wizard->addAction('jump'new HTML_QuickForm_Action_Jump());
  101.  
  102. // This is the action we should always define ourselves
  103. $wizard->addAction('process'new ActionProcess());
  104.  
  105. $wizard->run();
  106. ?>

Documentation generated on Mon, 11 Mar 2019 15:34:48 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.