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

Source for file simple.php

Documentation is available at simple.php

  1. <?php
  2. /**
  3.  * Usage example for HTML_QuickForm2_Controller: simple
  4.  *
  5.  * @author  Alexey Borzov <avb@php.net>
  6.  * @author  Bertrand Mansion <php@mamasam.com>
  7.  * @ignore
  8.  */
  9.  
  10. require_once 'HTML/QuickForm2.php';
  11. require_once 'HTML/QuickForm2/Controller.php';
  12.  
  13. // Load some default action handlers
  14. require_once 'HTML/QuickForm2/Controller/Action/Submit.php';
  15. require_once 'HTML/QuickForm2/Controller/Action/Display.php';
  16.  
  17. // Start the session, form-page values will be kept there
  18.  
  19. {
  20.     protected function populateForm()
  21.     {
  22.         $form $this->form;
  23.         $fs $form->addFieldset()->setLabel("Controller example 1: a simple form");
  24.  
  25.         $fs->addText("tstText"array('size'=>20'maxlength'=>50))
  26.            ->setLabel("Please enter something:")
  27.            ->addRule("required""Pretty please!");
  28.  
  29.         $fs->addSubmit($this->getButtonName('submit')array('value' => 'Send'));
  30.         $this->setDefaultAction('submit')
  31.              ->setAttribute('style''display:none');
  32.     }
  33. }
  34.  
  35. {
  36.     public function perform(HTML_QuickForm2_Controller_Page $page$name)
  37.     {
  38.         echo "Submit successful!<br>\n<pre>\n";
  39.         var_dump($page->getController()->getValue());
  40.         echo "\n</pre>\n";
  41.     }
  42. }
  43.  
  44. {
  45.     protected function renderForm(HTML_QuickForm2 $form)
  46.     {
  47. ?>
  48. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  49.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  50. <html xmlns="http://www.w3.org/1999/xhtml">
  51.   <head>
  52.     <style type="text/css">
  53. /* Set up custom font and form width */
  54. body {
  55.     margin-left: 10px;
  56.     font-family: Arial,sans-serif;
  57.     font-size: small;
  58. }
  59.  
  60. .quickform {
  61.     min-width: 500px;
  62.     max-width: 600px;
  63.     width: 560px;
  64. }
  65.  
  66. /* Use default styles included with the package */
  67.  
  68. <?php
  69.     if ('@data_dir@' != '@' 'data_dir@'{
  70.         $filename '@data_dir@/HTML_QuickForm2/quickform.css';
  71.     else {
  72.         $filename dirname(dirname(dirname(__FILE__))) '/data/quickform.css';
  73.     }
  74.     readfile($filename);
  75. ?>
  76.     </style>
  77.     <title>HTML_QuickForm2 simple controller example</title>
  78.   </head>
  79.   <body>
  80. <?php
  81.         echo $form;
  82. ?>
  83.   </body>
  84. </html>
  85. <?php
  86.     }
  87. }
  88.  
  89. $page = new SimplePage(new HTML_QuickForm2('page1'));
  90. $page->addHandler('process'new SimpleProcess());
  91. $page->addHandler('display'new SimpleDisplay());
  92.  
  93. $controller = new HTML_QuickForm2_Controller('Simple');
  94. $controller->addPage($page);
  95. $controller->run();
  96.  
  97. ?>

Documentation generated on Wed, 10 Apr 2019 08:56:11 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.