HTML_QuickForm_advmultiselect::getElementCss

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

Synopsis

require_once 'HTML/QuickForm/advmultiselect.php';

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

Description

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.

Parameter

boolean $raw

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

Throws

throws no exceptions thrown

Note

since version 0.4.0 (2005-06-25)

This function can not be called statically.

Example

<?php
require_once 'HTML/QuickForm.php';
require_once 
'HTML/QuickForm/advmultiselect.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);
$ams->setLabel(array('Fruit:''Available''Selected'));

// template for a single checkboxes multi-select element shape
$template '
<table{class}>
<!-- BEGIN label_3 --><tr><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
  <td>{selected}</td>
</tr>
</table>
'
;
$ams->setElementTemplate($template);

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');
$form->addGroup($buttons);
?>
<!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">
<head>
<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(); ?>
// -->
</style>
</head>
<body>
<?php
if ($form->validate()) {
    
$clean $form->getSubmitValues();

    echo 
'<pre>';
    
print_r($clean);
    echo 
'</pre>';
}
$form->display();
?>
</body>
</html>