* @package HTML_QuickForm_advmultiselect * @subpackage Examples * @access public * @example examples/qfams_multiple_1.php * qfams_multiple_1 source code * @link http://www.laurent-laville.org/img/qfams/screenshot/multiple1.png * screenshot (Image PNG, 566x392 pixels) 8.82 Kb */ require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/advmultiselect.php'; $form = new HTML_QuickForm('amsMultiple1'); $form->removeAttribute('name'); // XHTML compliance // same as default element template but wihtout the label (in first td cell) $withoutLabel = <<<_HTML   {error}
{element} _HTML; // more XHTML compliant // replace default element template with label, because submit button have no label $renderer =& $form->defaultRenderer(); $renderer->setElementTemplate($withoutLabel, 'send'); $fruit_array = array( 'apple' => 'Apple', 'orange' => 'Orange', 'pear' => 'Pear', 'banana' => 'Banana', 'cherry' => 'Cherry', 'kiwi' => 'Kiwi', 'lemon' => 'Lemon', 'lime' => 'Lime', 'tangerine' => 'Tangerine', ); $car_array = array( 'dodge' => 'Dodge', 'chevy' => 'Chevy', 'bmw' => 'BMW', 'audi' => 'Audi', 'porsche' => 'Porsche', 'kia' => 'Kia', 'subaru' => 'Subaru', 'mazda' => 'Mazda', 'isuzu' => 'Isuzu', ); // rendering with all default options $form->addElement('header', null, 'Advanced Multiple Select: default layout '); $ams1 =& $form->addElement('advmultiselect', 'cars', 'Cars:', $car_array); if (isset($_POST['cars'])) { $form->setDefaults(array('cars' => $_POST['cars'])); } // rendering with css selectors and API selLabel(), setButtonAttributes() $form->addElement('header', null, 'Advanced Multiple Select: custom layout '); $ams2 =& $form->addElement('advmultiselect', 'fruit', null, $fruit_array, array('size' => 5, 'class' => 'pool', 'style' => 'width:200px;' ) ); $ams2->setJsElement('fruit_'); $ams2->setLabel(array('Fruit:', 'Available', 'Selected')); $ams2->setButtonAttributes('add', array('value' => 'Add', 'name' => 'add1', 'class' => 'inputCommand' )); $ams2->setButtonAttributes('remove', array('value' => 'Remove', 'name' => 'remove1', 'class' => 'inputCommand' )); if (isset($_POST['fruit'])) { $form->setDefaults(array('fruit' => $_POST['fruit'])); } $form->addElement('submit', 'send', 'Send'); ?> HTML_QuickForm::advMultiSelect multiple example 1 validate()) { $clean = $form->getSubmitValues(); echo '
';
    print_r($clean);
    echo '
'; } $form->display(); ?>