* @package HTML_QuickForm_advmultiselect * @subpackage Examples * @access public * @example examples/qfams_custom_1.php * qfams_custom_1 source code * @link http://www.laurent-laville.org/img/qfams/screenshot/custom1.png * screenshot (Image PNG, 677x197 pixels) 4.80 Kb */ require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/advmultiselect.php'; $form = new HTML_QuickForm('amsCustom1'); $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', ); // rendering with QF renderer engine and template system $form->addElement('header', null, 'Advanced Multiple Select: custom layout '); $ams =& $form->addElement('advmultiselect', 'fruit', null, $fruit_array, array('size' => 5, 'class' => 'pool', 'style' => 'width:300px;' ) ); $ams->setLabel(array('Fruit:', 'Available', 'Selected')); $ams->setButtonAttributes('add', array('value' => 'Add >>', 'class' => 'inputCommand' )); $ams->setButtonAttributes('remove', array('value' => '<< Remove', 'class' => 'inputCommand' )); $template = ' {label_2} {label_3} {unselected} {selected} {add} {remove} '; $ams->setElementTemplate($template); if (isset($_POST['fruit'])) { $form->setDefaults(array('fruit' => $_POST['fruit'])); } $form->addElement('submit', 'send', 'Send'); ?> HTML_QuickForm::advMultiSelect custom example 1 getElementJs(false); ?> validate()) { $clean = $form->getSubmitValues(); echo '
';
    print_r($clean);
    echo '
'; } $form->display(); ?>