HTML_QuickForm_advmultiselect::getElementCss() – Gets default element stylesheet for a single multi-select shape render


require_once 'HTML/QuickForm/advmultiselect.php';

string HTML_QuickForm_advmultiselect::getElementCss ( boolean $raw = TRUE )


If your browser does not support javascript, or for any reasons you have choosen to disable it, then your only possibility is to use the single checkboxes multi-select shape of HTML_QuickForm_advmultiselect element.

You get a more or less decent result with just the basic settings, but it is also highly configurable, so you can almost get what you want.

The basic settings can be applied with just the placeholder {stylesheet} into your template element. It can also be applied with getElementCss() method. If you does not have existing style tags in your html page, you must call the method with FALSE argument. Default behavior returns only the raw css data without style tags. Useful when using with template engine.


boolean $raw

(optional) html output with style tags or just raw data


throws no exceptions thrown


since version 0.4.0 (2005-06-25)

This function can not be called statically.


require_once 'HTML/QuickForm.php';

$form = new HTML_QuickForm('ams');
$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);

// template for a single checkboxes multi-select element shape
$template '
<!-- BEGIN label_3 --><tr><th>{label_3}</th></tr><!-- END label_3 -->

if (
// 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');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="" xml:lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>HTML_QuickForm::advMultiSelect custom example 4b</title>
<style type="text/css">
body {
  background-color: #FFF;
  font-family: Verdana, Arial, helvetica;
  font-size: 10pt;
<?php echo $ams->getElementCss(); ?>
// -->
if ($form->validate()) {
$clean $form->getSubmitValues();

Template-based renderer (Previous) Returns the javascript code generated to handle this element (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.