Source for file function.pnformcheckbox.php
Documentation is available at function.pnformcheckbox.php
* @copyright (c) 2006, Zikula Development Team
* @link http://www.zikula.org
* @version $Id: function.pnformcheckbox.php 24342 2008-06-06 12:03:14Z markwest $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package Zikula_Template_Plugins
* Plugin to generate a checkbox for true/false selection.
* Set to true when checkbox is checked, false otherwise.
* Enable or disable read only mode
* Data field name for looking up initial data
* The name stored here is used to lookup initial data for the plugin in the render's variables.
* Defaults to the ID of the plugin. See also tutorials on the Zikula site.
* Enable or disable use of $dataField
* Group name for this input
* The group name is used to locate data in the render (when databased) and to restrict which
* plugins to do validation on (to be implemented).
* @see pnFormRender::pnFormGetValues()
* @see pnFormRender::pnFormIsValid()
* HTML input name for this plugin. Defaults to the ID of the plugin.
return __FILE__ ; // FIXME: should be found in smarty's data???
function create(&$render, $params)
// Load all special and non-string parameters
// - the rest are fetched automatically
function load(&$render, &$params)
$this->loadValue($render, $render->get_template_vars());
if ($this->group == null)
$idHtml = $this->getIdHtml();
$readOnlyHtml = ($this->readOnly ? " disabled=\"disabled\"" : '');
$checkedHtml = ($this->checked ? " checked=\"checked\"" : '');
$attributes = $this->renderAttributes($render);
$result = "<input type=\"checkbox\" value=\"1\" class=\"cbx\"{ $idHtml}{ $nameHtml}{ $readOnlyHtml}{ $checkedHtml}{ $attributes}/> ";
function decode(&$render)
// Do not read new value if readonly (evil submiter might have forged it)
$this->checked = (FormUtil::getPassedValue($this->inputName, null, 'REQUEST') == null ? false : true);
function saveValue(&$render, &$data)
if ($this->group == null)
if (!array_key_exists($this->group, $data))
$data[$this->group] = array();
function smarty_function_pnformcheckbox($params, &$render)
return $render->pnFormRegisterPlugin('pnFormCheckbox', $params);
|