Location: PHPKode > projects > FiForms Framework > FiForms/FiForms-includes/FiForms_iCheck.inc.php
<?php

/*
*******************************************************************************

    FiForms -- A collection of PHP classes designed 
    to facilitate rapid development of web-database software

    Copyright (C) 2003-2008  Daniel McFeeters

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


    The original author of this library can be contacted at the following 
    address:

    Daniel McFeeters
    182 Baker Rd.
    Faubush, KY 42544-6526
    email:databases [at] fiforms [dot] org
    http://www.fiforms.org/


iCheck class
Project Started April 23, 2004
*******************************************************************************
FiForms_iCheck.inc.php

iCheck Definition File

This file contains the definitions for the iCheck input class 

*******************************************************************************
*/

require_once("FiForms_iInput.inc.php");

/* ?><code><?php */

$FIFORM_XML_INPUTS[] = 'f:iCheck';

    class iCheck extends iInput
    // Output an html checkbox input.
    // Usually bound to boolean or tinyint field
    // 0=unchecked; +-0=checked
    {
        var $checked;
        var $checkedX;

        function iCheck()
        {
            $this->iInput(func_get_args());
        }

        function formatOutput()
        {
            if($this->value == 0)
            {
                $this->checked = " ";
                $this->checkedX = " ";
            }
            else
            {
                $this->checked = " checked=\"checked\" ";
                //$this->checkedX = "X";
                $this->checkedX = "<div style=\"position: relative; top: -5pt; left: 3pt; font-size: 20pt; margin-bottom: -12pt; margin-right: 5pt;\">&#8226;</div>";
                //$this->checkedX = "&#8226;";
            }
            if($this->readOnly)
            {
                return($this->checkedX);
            }
            else
            {
                return("<input type=\"checkbox\" name=\"$this->dbField\" $this->checked ".
                "$this->otherTags />");
            }
        }  // function formatOutput

        function getValueToSave()
        {
            if(!array_key_exists($this->dbField,$_POST))
            {
                return false;
            }
            //die($_POST[$this->dbField]);
            if($_POST[$this->dbField] == "on")
            {
                $this->valueToSave = '1';
            }
            else
            {
                $this->valueToSave = '0';
            } // if
            return TRUE;
        }  // function getValueToSave
        
    } // class iText

/* ?></code><?php */
?>
Return current item: FiForms Framework