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

Source for file qfams_basic_1.php

Documentation is available at qfams_basic_1.php

  1. <?php
  2. /**
  3.  * Basic advMultiSelect HTML_QuickForm element
  4.  * without any customization.
  5.  *
  6.  * @version    $Id: qfams_basic_1.php,v 1.4 2008/04/26 17:25:59 farell Exp $
  7.  * @author     Laurent Laville <pear@laurent-laville.org>
  8.  * @package    HTML_QuickForm_advmultiselect
  9.  * @subpackage Examples
  10.  * @access     public
  11.  * @example    examples/qfams_basic_1.php
  12.  *              qfams_basic_1 source code
  13.  * @link       http://www.laurent-laville.org/img/qfams/screenshot/basic1.png
  14.  *              screenshot (Image PNG, 406x247 pixels) 4.95 Kb
  15.  */
  16.  
  17. require_once 'HTML/QuickForm.php';
  18. require_once 'HTML/QuickForm/advmultiselect.php';
  19.  
  20. $form = new HTML_QuickForm('amsBasic1');
  21. $form->removeAttribute('name');        // XHTML compliance
  22.  
  23. // same as default element template but wihtout the label (in first td cell)
  24. $withoutLabel = <<<_HTML
  25. <tr valign="top">
  26.     <td align="right">
  27.         &nbsp;
  28.     </td>
  29.     <td align="left">
  30.         <!-- BEGIN error --><span style="color: #ff0000;">{error}</span><br /><!-- END error -->{element}
  31.     </td>
  32. </tr>
  33. _HTML;
  34.  
  35. // more XHTML compliant
  36. // replace default element template with label, because submit button have no label
  37. $renderer =$form->defaultRenderer();
  38. $renderer->setElementTemplate($withoutLabel'send');
  39.  
  40. $car_array = array(
  41.     'dodge'     =>  'Dodge',
  42.     'chevy'     =>  'Chevy',
  43.     'bmw'       =>  'BMW',
  44.     'audi'      =>  'Audi',
  45.     'porsche'   =>  'Porsche',
  46.     'kia'       =>  'Kia',
  47.     'subaru'    =>  'Subaru',
  48.     'mazda'     =>  'Mazda',
  49.     'isuzu'     =>  'Isuzu',
  50. );
  51.  
  52. // rendering with all default options
  53. $form->addElement('header'null'Advanced Multiple Select: default layout ');
  54.  
  55. $form->addElement('advmultiselect''cars''Cars:'$car_array);
  56.  
  57. if (isset($_POST['cars'])) {
  58.     $form->setDefaults(array('cars' => $_POST['cars']));
  59. }
  60.  
  61. $form->addElement('submit''send''Send');
  62. ?>
  63. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  64.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  65. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  66. <head>
  67. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  68. <title>HTML_QuickForm::advMultiSelect basic example 1</title>
  69. <style type="text/css">
  70. <!--
  71. body {
  72.   background-color: #FFF;
  73.   font-family: Verdana, Arial, helvetica;
  74.   font-size: 10pt;
  75. }
  76.  -->
  77. </style>
  78. </head>
  79. <body>
  80. <?php
  81. if ($form->validate()) {
  82.     $clean $form->getSubmitValues();
  83.  
  84.     echo '<pre>';
  85.     print_r($clean);
  86.     echo '</pre>';
  87. }
  88. $form->display();
  89. ?>
  90. </body>
  91. </html>

Documentation generated on Sat, 26 Apr 2008 14:30:08 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.