Source for file qfams_custom_3.php
Documentation is available at qfams_custom_3.php
* Custom advMultiSelect HTML_QuickForm element
* loading values with fancy attributes (disabled, ...)
* @version $Id: qfams_custom_3.php,v 1.4 2008/04/26 17:25:59 farell Exp $
* @author Laurent Laville <pear@laurent-laville.org>
* @package HTML_QuickForm_advmultiselect
* @example examples/qfams_custom_3.php
* qfams_custom_3 source code
* @link http://www.laurent-laville.org/img/qfams/screenshot/custom3.png
* screenshot (Image PNG, 374x275 pixels) 4.96 Kb
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/advmultiselect.php';
$form = new HTML_QuickForm ('amsCustom3');
$form->removeAttribute ('name'); // XHTML compliance
// same as default element template but wihtout the label (in first td cell)
<!-- BEGIN error --><span style="color: #ff0000;">{error}</span><br /><!-- END error -->{element}
// replace default element template with label, because submit button have no label
$renderer = & $form->defaultRenderer ();
$renderer->setElementTemplate ($withoutLabel, 'send');
'pear' => array ('Pear', array ('disabled' => 'disabled')),
'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 , null ,
foreach ($fruit_array as $key => $data) {
$attr = isset ($data[1 ]) ? $data[1 ] : null;
$ams->addOption ($data[0 ], $key, $attr);
$ams->setLabel (array ('Fruit:', 'Available', 'Selected'));
$ams->setButtonAttributes ('add', array ('value' => 'Add >>',
'class' => 'inputCommand'
$ams->setButtonAttributes ('remove', array ('value' => '<< Remove',
'class' => 'inputCommand'
<!-- BEGIN label_2 --><tr><th align="center">{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th align="center">{label_3}</th></tr><!-- END label_3 -->
$ams->setElementTemplate ($template);
if (isset ($_POST['fruit'])) {
$form->setDefaults (array ('fruit' => $_POST['fruit']));
$form->addElement ('submit', 'send', 'Send');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>HTML_QuickForm::advMultiSelect custom example 3</title>
font-family: Verdana, Arial, helvetica;
background-color: lightyellow;
background-color: lightblue;
background-color: #d0d0d0;
border: 1px solid #7B7B88;
<?php echo $ams->getElementJs (false ); ?>
$clean = $form->getSubmitValues ();
Documentation generated on Sat, 26 Apr 2008 14:30:10 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|