Location: PHPKode > scripts > HTML_QuickForm_ComboBox > html_quickform_combobox/examples/sample.php
<?php
/* vim: set number autoindent tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * Example of usage for PEAR class HTML_QuickForm_ComboBox
 *
 * @author     Fabio Ambrosanio <hide@address.com>
 * @version    0.1.0
 * @package    HTML_QuickForm_ComboBox
 *
 * $Id: sample.php,v 1.3 2006/11/29 21:28:18 fabamb Exp $
 */
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/combobox.php';

$form = new HTML_QuickForm('form');

$form->addElement('combobox', 'combo1', 'Combo with button:', range(1, 10), array('buttonValue' => '...'));

$images = array( 'arrowImage' => 'arrow.gif', 'arrowImageDown' => 'arrow_down.gif', 'arrowImageOver' => 'arrow_over.gif');
$form->addElement('combobox', 'combo2', 'Combo with images:', array('Italia', 'United Kingdom', 'France'), $images);

$values = array('it' => 'Italia', 'uk' => 'United Kingdom', 'fr' => 'France');
$form->addElement('combobox', 'combo3', 'Combo with images and associative array:', $values, $images);
$elem =& $form->addElement('combobox', 'combo1', 'Combo with different CSS:', range(100, 200), array('buttonValue' => '...'));
$elem->setCSS('combobox2.css', '.', array(
	'inputClass' => 'comboBoxInput2',      // style class of input text field
));

$form->addElement('text', 'required', 'For error check:');
$form->addRule('required', 'Field required.', 'required');
$form->addElement('submit', null, 'Submit');

// Tries to validate the form
if ($form->validate()) {
    // Form is validated, then processes the data
    $form->freeze();
    $form->process('myProcess', false);
    echo "\n<HR>\n";
}

/**
 * Process callback
 * @ignore
 */
function myProcess($values)
{
    echo '<pre>';
    var_dump($values);
    echo '</pre>';
}

$form->display();
?>
Return current item: HTML_QuickForm_ComboBox