HTML_QuickForm_advmultiselect::setElementTemplate

HTML_QuickForm_advmultiselect::setElementTemplate() – Sets element template

Synopsis

require_once 'HTML/QuickForm/advmultiselect.php';

void HTML_QuickForm_advmultiselect::setElementTemplate ( string $html = NULL , boolean $js = TRUE )

Description

It is so easy to re-arrange select boxes, headers and buttons position. The template is a bit of html code with reserved placeholders words. They are:

stylesheet

The CSS delimited by the style tags required only for the single multi-select with checkboxes shape. Not included in the default template. You can use instead, the getElementCss() method.

javascript

The JavaScript delimited by the script tags required to manage item of both multi-select boxes. If it is not included, you can use instead, the getElementJs() method.

class

A CSS class identifier in one of your stylesheets that is the default table layout. Default values are:


<table border="0" cellpadding="10" cellspacing="0">
label_2

The unselected list header

label_3

The selected list header

unselected

The unselected list.

selected

The selected list.

add

The add button to swap one (or more) item from the unselected to the selected list.

remove

The remove button to swap one (or more) item back from the selected to the unselected list.

moveup

The button to move one item of the selected list to the top.

movedown

The button to move one item of the selected list to the bottom.

movetop

The button to move one item of the selected list directly at the top of the list

movebottom

The button to move one item of the selected list directly at the bottom of the list

Parameter

string $html

(optional) The HTML surrounding select boxes and buttons

boolean $js

(optional) if we need to include qfams javascript handler

Throws

throws no exceptions thrown

Note

since version 0.4.0 (2005-06-25)

This function can not be called statically.

Example

In this partial example, the fruit list select boxes are set to vertical alignement with images for the 'add' and 'remove' buttons. Default presentation are horizontal alignment with input text buttons in the middle side.

<?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',
);

$ams =& $form->addElement('advmultiselect''fruit'null$fruit_array);
$ams->setLabel(array('Fruit:''Available''Selected'));
$ams->setButtonAttributes('add',    array('type' => 'image''src' => '/img/down.png'));
$ams->setButtonAttributes('remove', array('type' => 'image''src' => '/img/up.png'));

// vertical select box with image buttons as selector
$template '
<table{class}>
<!-- BEGIN label_2 --><tr><th align="center">{label_2}</th></tr><!-- END label_2 -->
<tr>
  <td>{unselected}</td>
</tr>
<tr>
  <td align="center">{add}{remove}</td>
</tr>
<tr>
  <td>{selected}</td>
</tr>
<!-- BEGIN label_3 --><tr><th align="center">{label_3}</th></tr><!-- END label_3 -->
</table>'
;
$ams->setElementTemplate($template);

// ....
?>
Returns the javascript code generated to handle this element (Previous) Examples appendix (Next)
Last updated: Mon, 24 Nov 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.