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

Source for file example.php

Documentation is available at example.php

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  5. <title>HTML_QuickForm_altselect - Example Usage</title>
  6. </head>
  7.  
  8. <body>
  9. <?php
  10.  
  11. require_once 'HTML/QuickForm.php';
  12.  
  13. // Include altselect.php after QuickForm, so that the plugin can be loaded
  14. require_once 'HTML/QuickForm/altselect.php';
  15.  
  16.  
  17. $form =new HTML_QuickForm('test_altselect');
  18.  
  19.  
  20. // Add the altselect element, using the same arguments as you would a normal select element
  21. $altselect =$form->addElement('altselect''test''Select a value:',
  22.   array('a' => 'A',
  23.         'b' => 'B',
  24.         'c' => 'C'));
  25.  
  26. // Use the setMultiple() method, just as in HTML_QuickForm_select
  27. // to turn the radio buttons into checkboxes
  28. $altselect->setMultiple(true);
  29.  
  30. // Use setIncludeOther() to include the 'other' textfield for other possible values
  31. $altselect->setIncludeOther(true);
  32.  
  33. // Use setSelected(), just as in HTML_QuickForm_select
  34. // to set the default values
  35. $altselect->setSelected('b');
  36.  
  37.  
  38. $form->addElement('submit''submit''Submit');
  39.  
  40. if ($form->validate()) {
  41.  
  42.     // The exported value will either be a scalar or an array depending on what was posted,
  43.     // just as it would with HTML_QuickForm_select
  44.     $value $form->exportValue('test');
  45.     
  46.     echo '<p>The result is: '.var_export($valuetrue).'</p>';
  47. }
  48.  
  49. $form->display();
  50.  
  51. ?>
  52. </body>
  53. </html>

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