3 * Template_Lite {html_checkbox} function plugin
7 * Purpose: Creates a checkbox
9 * - name = the name of the checkbox
10 * - value = optional value for the checkbox
11 * - checked = boolean - whether the box is checked or not
12 * Author: Paul Lockaby <paul@paullockaby.com>
14 function tpl_function_html_checkboxes($params, &$tpl)
16 require_once("shared.escape_chars.php");
22 foreach($params as $_key => $_value)
31 if ($_key == 'true' ||
$_key == 'yes' ||
$_key == 'on')
43 $extra .= ' ' . $_key . '="' . tpl_escape_chars($_value) . '"';
47 throw new Template_Exception("html_checkbox: attribute '$_key' cannot be an array", $tpl);
52 if (!isset($name) ||
empty($name))
54 throw new Template_Exception("html_checkbox: missing 'name' parameter", $tpl);
58 $toReturn = '<input type="checkbox" name="' . tpl_escape_chars($name) . '"';
61 $toReturn .= ' checked';
65 $toReturn .= ' value="' . tpl_escape_chars($value) . '"';
67 $toReturn .= ' ' . $extra . ' />';