Live counters
Вернуться к: Advanced features
Live counters
When selection lists have lot of item, we don't expect to count each item one by one.
When it's so easy to count selections on server side, once the form is submitted, there is no ability to do the same in live, until new feature "Live counter".
This feature require HTML_QuickForm_advmultiselect package version 1.3.0 or better.
A full example is given in appendices. See live counter combines with multiple elements
Identification and localisation
Implements display of live counters (selected, unselected items) is fully independant. Its requires for each counter to add new placeholders.
For item unselected list, these placehodlers are :
-
{unselected_count} for localisation (where the counter value will be displayed)
-
{unselected_count_id} for identification by DOM API (ID attribut of any HTML tag)
For item selected list, these placehodlers are :
-
{selected_count} for localisation (where the counter value will be displayed)
-
{selected_count_id} for identification by DOM API (ID attribut of any HTML tag)
<?php
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/advmultiselect.php';
// ...
$form = new HTML_QuickForm('amsLC');
$ams =& $form->addElement('advmultiselect', 'cars', null, $car_array);
// ...
?>
Counters identifiers (attribut ID) used by DOM API are identified by string : advmultiselect element name concat with "_selected" or "_unselected" suffix (depending of lists).
Result for example (previous code) : cars_selected or cars_unselected
advmultiselect element with single list (with checkboxes) are identified by string : "qfams_" prefix concat with advmultiselect element name
Result for example (previous code) : qfams_cars
advmultiselect element with double list are identified with string : prefix "__" (two underscores) concat with advmultiselect element name for unselected list. While selection list (selected item) is identified with string : prefix "_" (one underscore) concat with advmultiselect element name.
Result for example (previous code) : __cars and _cars
advmultiselect elements with single list (with checkboxes) are identified by DOM API with only {selected_count} and {selected_count_id} placeholders. No need to add {unselected_count} and {unselected_count_id} placeholders.
See example in appendix Live counter combines with multiple elements, and template definition $template1 lines 49-57.
Вернуться к: Advanced features