SwatML for this demo:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE swatml SYSTEM "http://swat.silverorange.com/swatml1.dtd">
<swatml>
<widget class="SwatForm" id="my_form">
<widget class="SwatFieldset">
<property name="title">Individual Checkboxes</property>
<widget class="SwatFormField">
<property name="title">Check 1</property>
<widget class="SwatCheckbox" id="check1">
</widget>
</widget>
<widget class="SwatFormField">
<property name="title">Check 2</property>
<widget class="SwatCheckbox" id="check2">
</widget>
</widget>
</widget>
<widget class="SwatFieldset">
<property name="title">Checkbox Entry List</property>
<widget class="SwatCheckboxEntryList" id="checkbox_entry_list"/>
</widget>
<widget class="SwatFieldset">
<property name="title">Checkbox List</property>
<widget class="SwatCheckboxList" id="checkbox_list">
<property name="values[]" type="integer">1</property>
<property name="columns" type="integer">2</property>
</widget>
</widget>
<widget class="SwatFieldset">
<property name="title">Checkbox Tree</property>
<widget class="SwatCheckboxTree" id="checkbox_tree">
<property name="values[]" type="integer">1</property>
<property name="values[]" type="integer">4</property>
<property name="values[]" type="integer">7</property>
</widget>
</widget>
<widget class="SwatFieldset">
<property name="title">Expandable Checkbox Tree</property>
<widget class="SwatExpandableCheckboxTree" id="expandable_checkbox_tree">
<property name="values[]" type="integer">2</property>
<property name="values[]" type="integer">3</property>
<property name="values[]" type="integer">8</property>
</widget>
</widget>
<widget class="SwatFooterFormField">
<widget class="SwatButton" id="done" />
</widget>
</widget>
</swatml>
PHP for this demo:
<?php
/* vim: set noexpandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
require_once 'Demo.php';
/**
* A demo using checkboxes
*
* @package SwatDemo
* @copyright 2005-2007 silverorange
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
*/
class CheckboxDemo extends Demo
{
// {{{ public function buildDemoUI()
public function buildDemoUI(SwatUI $ui)
{
// regular checkbox tree
$tree = new SwatDataTreeNode(null, 'Root');
$apples = new SwatDataTreeNode(null, 'Apple');
$apples->addChild(new SwatDataTreeNode(0, 'McIntosh'));
$apples->addChild(new SwatDataTreeNode(1, 'Courtland'));
$apples->addChild(new SwatDataTreeNode(2, 'Golden Delicious'));
$apples->addChild(new SwatDataTreeNode(3, 'Fuji'));
$apples->addChild(new SwatDataTreeNode(4, 'Granny Smith'));
$oranges = new SwatDataTreeNode(null, 'Orange');
$oranges->addChild(new SwatDataTreeNode(5, 'Navel'));
$blood_oranges = new SwatDataTreeNode(null, 'Blood');
$blood_oranges->addChild(new SwatDataTreeNode(6, 'Doble Fina'));
$blood_oranges->addChild(new SwatDataTreeNode(7, 'Entrefina'));
$blood_oranges->addChild(new SwatDataTreeNode(8, 'Sanguinelli'));
$oranges->addChild($blood_oranges);
$oranges->addChild(new SwatDataTreeNode(9, 'Florida'));
$oranges->addChild(new SwatDataTreeNode(10, 'California'));
$oranges->addChild(new SwatDataTreeNode(11, 'Mandarin'));
$tree->addChild($apples);
$tree->addChild($oranges);
$checkbox_tree = $ui->getWidget('checkbox_tree');
$checkbox_tree->setTree($tree);
// expandable checkbox tree
$tree = new SwatDataTreeNode(null, 'Root');
$apples = new SwatDataTreeNode(null, 'Apple');
$apples->addChild(new SwatDataTreeNode(0, 'McIntosh'));
$apples->addChild(new SwatDataTreeNode(1, 'Courtland'));
$apples->addChild(new SwatDataTreeNode(2, 'Golden Delicious'));
$apples->addChild(new SwatDataTreeNode(3, 'Fuji'));
$apples->addChild(new SwatDataTreeNode(4, 'Granny Smith'));
$oranges = new SwatDataTreeNode(13, 'Orange');
$oranges->addChild(new SwatDataTreeNode(5, 'Navel'));
$blood_oranges = new SwatDataTreeNode(14, 'Blood');
$blood_oranges->addChild(new SwatDataTreeNode(6, 'Doble Fina'));
$blood_oranges->addChild(new SwatDataTreeNode(7, 'Entrefina'));
$blood_oranges->addChild(new SwatDataTreeNode(8, 'Sanguinelli'));
$oranges->addChild($blood_oranges);
$oranges->addChild(new SwatDataTreeNode(9, 'Florida'));
$oranges->addChild(new SwatDataTreeNode(10, 'California'));
$oranges->addChild(new SwatDataTreeNode(11, 'Mandarin'));
$tree->addChild($apples);
$tree->addChild($oranges);
$expandable_checkbox_tree = $ui->getWidget('expandable_checkbox_tree');
$expandable_checkbox_tree->setTree($tree);
// checkbox list
$checkbox_list_options = array(
0 => 'McIntosh',
1 => 'Courtland',
2 => 'Golden Delicious',
3 => 'Fuji',
4 => 'Granny Smith');
$checkbox_list = $ui->getWidget('checkbox_list');
$checkbox_list->addOptionsByArray($checkbox_list_options);
// checkbox entry list
$checkbox_entry_list_options = array(
0 => 'Apple',
1 => 'Orange',
2 => 'Banana',
3 => 'Pear',
4 => 'Pineapple',
5 => 'Kiwi');
$checkbox_entry_list = $ui->getWidget('checkbox_entry_list');
$checkbox_entry_list->addOptionsByArray($checkbox_entry_list_options);
}
// }}}
}
?>