* @package HTML_QuickForm_advmultiselect * @subpackage Examples * @access public * @example examples/qfams_custom_7.php * qfams_custom_7 source code * @link http://www.laurent-laville.org/img/qfams/screenshot/custom7.png * screenshot (Image PNG, 640x525 pixels) 160 Kb */ require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/advmultiselect.php'; $form = new HTML_QuickForm('amsCustom7'); $form->removeAttribute('name'); // XHTML compliance $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('class' => 'pool', 'style' => 'width:200px;') ); $ams->setLabel(array('Fruit:', 'Available', 'Selected')); $ams->setButtonAttributes('add' , 'class=inputCommand'); $ams->setButtonAttributes('remove' , 'class=inputCommand'); $ams->setButtonAttributes('all' , 'class=inputCommand'); $ams->setButtonAttributes('none' , 'class=inputCommand'); $ams->setButtonAttributes('toggle' , 'class=inputCommand'); $ams->setButtonAttributes('moveup' , 'class=inputCommand'); $ams->setButtonAttributes('movedown', 'class=inputCommand'); // template for a single checkboxes multi-select element shape $template1 = ' {label_3}  {selected} {all}
{none}
{toggle} '; // template for a dual multi-select element shape $template2 = ' {label_2}  {label_3} {unselected} {add}
{remove}

{all}
{none}

{moveup}
{movedown}
{selected} '; if (isset($_POST['multiselect'])) { $ams->setElementTemplate($template2); } else { $ams->setElementTemplate($template1); } if ($_SERVER['REQUEST_METHOD'] == 'GET') { // fruit default values already selected without any end-user actions $form->setDefaults(array('fruit' => array('kiwi','lime'))); } elseif (isset($_POST['fruit'])) { // fruit end-user selection $form->setDefaults(array('fruit' => $_POST['fruit'])); } $buttons[] =& $form->createElement('submit', null, 'Submit'); $buttons[] =& $form->createElement('reset', null, 'Reset'); $buttons[] =& $form->createElement('checkbox', 'multiselect', null, 'use dual select boxes layout'); $form->addGroup($buttons, null, ' '); ?> HTML_QuickForm::advMultiSelect custom example 7 getElementJs(false); ?> validate()) { $clean = $form->getSubmitValues(); echo '
';
    print_r($clean);
    echo '
'; } $form->display(); ?>