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

Source for file index.php

Documentation is available at index.php

  1. <?php
  2. // $Id$
  3. require_once 'HTML/QuickForm.php';
  4. require_once 'HTML/QuickForm/livesearch_select.php';
  5. require_once 'myfunction.php';
  6. // Instantiate the HTML_QuickForm object
  7. $form = new HTML_QuickForm('firstForm');
  8.  
  9.  
  10. // Add some elements to the form
  11. $form->addElement('header'null'QuickForm example');
  12.  
  13. $form->addElement('livesearch_select''Nome''Example: Live Select, <br>select a name and return an ID <br>(useful for dropdown lists)',
  14.                  array(
  15.                       'elementId' => 'search'//element id
  16.                       'callback' => array('Test''getTestName'),//callback function to retrieve value from ID selection
  17. //                       'dbh' => $db,//optional handler for callback function
  18.                       'style' => '',//optional class for style not set or '' ==> default
  19.                       'divstyle' => '',//optional class for style not set or '' ==> default
  20.                       'ulstyle' => '',//optional class for style not set or '' ==> default
  21.                       'listyle' => '',//optional class for style not set or '' ==> default
  22.                       'searchZeroLength' => 1//enable the search request with 0 length keyword(Default 0)
  23.                       'buffer' => 350//set the interval single buffer send time (ms)
  24.                       'printStyle' => 1//anything != 0 will render css inline(Default 1), 0 => the default style will not be rendered, you should put it in your style.css(XHTML fix)
  25.                       'autoComplete' => 1//if 0 the autocomplete attribute will not be set. Default not set;
  26.                       'autoserverPath' => '' //path to auto_server.php file with trailing slash NOTE: check path for all files included in autoserver.php
  27.                       ),
  28.                       array('size' => '50')
  29.                   );
  30. $form->addElement('livesearch_select''Nome2''Example2: Live Select, <br>select a name and return an ID <br>(useful for dropdown lists)',
  31.                  array(
  32.                       'elementId' => 'search2'//element id
  33.                       'callback' => array('Test''getTestName2'),//callback function to retrieve ID from selection
  34. //                       'dbh' => $db,//optional handler for callback function
  35.                       ),
  36.                   'size=30'
  37.                   );
  38. $form->addElement('text''required_field''[errorTest]Some data:');
  39. $form->addElement('submit'null'View'array('id'=>'submit'));
  40. $form->addRule('required_field''Data required''required'null'server');
  41. $form->addRule('Nome''Data required''required'null'server');
  42. //example set default value only if form is not submitted
  43. if (!isset($_POST['Nome2']) ) {
  44.     $el $form->getElement('Nome2');
  45.     $el->setValue(2);
  46. }
  47. if ($form->validate()) {
  48.   echo"<pre>";print_r($_POST);echo"</pre>";
  49.   $form->freeze();
  50. }
  51. // Output the form
  52. ?>
  53. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  54. <html>
  55. <head>
  56.   <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
  57.   <title>Livesearch QuickForm Test</title>
  58.   <link rel="stylesheet" href="style.css" type="text/css">
  59. </head>
  60. <body>
  61. <p style="font-size:14px;">HTML_AJAX dependent QF_Livesearch DROPDOWN<br>
  62. In this example we can find something from database, such a Fourm Post or a word in a News Post...<br>
  63. This type of livesearch is useful when you have a form with a dropdown list with a large number of row.<br>
  64. With HTML_QuickForm, you can easily do the trick ;).</p>
  65. <?php
  66. $form->display();
  67. ?>
  68. </body>
  69. </html>

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