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

Source for file simple.php

Documentation is available at simple.php

  1. <?php
  2. /**
  3.  * Example 1 for HTML_QuickForm_Controller: using the Controller
  4.  * infrastructure to create and process the basic single-page form
  5.  *
  6.  * @version SVN: $Id: simple.php 289084 2009-10-02 06:53:09Z avb $
  7.  * @author  Alexey Borzov <avb@php.net>
  8.  * @ignore
  9.  */
  10.  
  11. require_once 'HTML/QuickForm/Controller.php';
  12.  
  13. // Load some default action handlers
  14. require_once 'HTML/QuickForm/Action/Submit.php';
  15. require_once 'HTML/QuickForm/Action/Display.php';
  16.  
  17.  
  18. {
  19.     function buildForm()
  20.     {
  21.         $this->_formBuilt = true;
  22.  
  23.         $this->addElement('header',     null'Controller example 1: a simple form');
  24.         $this->addElement('text',       'tstText''Please enter something:'array('size'=>20'maxlength'=>50));
  25.         // Bind the button to the 'submit' action
  26.         $this->addElement('submit',     $this->getButtonName('submit')'Send');
  27.  
  28.         $this->applyFilter('tstText''trim');
  29.         $this->addRule('tstText''Pretty please!''required');
  30.  
  31.         $this->setDefaultAction('submit');
  32.     }
  33. }
  34.  
  35.  
  36. {
  37.     function perform(&$page$actionName)
  38.     {
  39.         echo "Submit successful!<br>\n<pre>\n";
  40.         var_dump($page->exportValues());
  41.         echo "\n</pre>\n";
  42.     }
  43. }
  44.  
  45. $page =new SimplePage('page1');
  46.  
  47. // We actually add these handlers here for the sake of example
  48. // They can be automatically loaded and added by the controller
  49. $page->addAction('display'new HTML_QuickForm_Action_Display());
  50. $page->addAction('submit'new HTML_QuickForm_Action_Submit());
  51.  
  52. // This is the action we should always define ourselves
  53. $page->addAction('process'new ActionProcess());
  54.  
  55. $controller =new HTML_QuickForm_Controller('simpleForm');
  56. $controller->addPage($page);
  57. $controller->run();
  58. ?>

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