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

Source for file sample.php

Documentation is available at sample.php

  1. <?php
  2. /* vim: set number autoindent tabstop=4 shiftwidth=4 softtabstop=4: */
  3.  
  4. /**
  5. * Example of usage for PEAR class HTML_QuickForm_ComboBox
  6. *
  7. * @author Fabio Ambrosanio <fabio@ambrosanio.com>
  8. * @version 0.1.0
  9. * @package HTML_QuickForm_ComboBox
  10. *
  11. * $Id: sample.php,v 1.3 2006/11/29 21:28:18 fabamb Exp $
  12. */
  13. require_once 'HTML/QuickForm.php';
  14. require_once 'HTML/QuickForm/combobox.php';
  15.  
  16. $form = new HTML_QuickForm('form');
  17.  
  18. $form->addElement('combobox', 'combo1', 'Combo with button:', range(1, 10), array('buttonValue' => '...'));
  19.  
  20. $images = array( 'arrowImage' => 'arrow.gif', 'arrowImageDown' => 'arrow_down.gif', 'arrowImageOver' => 'arrow_over.gif');
  21. $form->addElement('combobox', 'combo2', 'Combo with images:', array('Italia', 'United Kingdom', 'France'), $images);
  22.  
  23. $values = array('it' => 'Italia', 'uk' => 'United Kingdom', 'fr' => 'France');
  24. $form->addElement('combobox', 'combo3', 'Combo with images and associative array:', $values, $images);
  25. $elem =& $form->addElement('combobox', 'combo1', 'Combo with different CSS:', range(100, 200), array('buttonValue' => '...'));
  26. $elem->setCSS('combobox2.css', '.', array(
  27. 'inputClass' => 'comboBoxInput2', // style class of input text field
  28. ));
  29.  
  30. $form->addElement('text', 'required', 'For error check:');
  31. $form->addRule('required', 'Field required.', 'required');
  32. $form->addElement('submit', null, 'Submit');
  33.  
  34. // Tries to validate the form
  35. if ($form->validate()) {
  36. // Form is validated, then processes the data
  37. $form->freeze();
  38. $form->process('myProcess', false);
  39. echo "\n<HR>\n";
  40. }
  41.  
  42. /**
  43. * Process callback
  44. * @ignore
  45. */
  46. function myProcess($values)
  47. {
  48. echo '<pre>';
  49. var_dump($values);
  50. echo '</pre>';
  51. }
  52.  
  53. $form->display();
  54. ?>

Documentation generated on Wed, 29 Nov 2006 22:46:19 +0100 by phpDocumentor 1.3.0RC3