Cnz_Html
[ class tree: Cnz_Html ] [ index: Cnz_Html ] [ all elements ]

Source for file Checkbox.php

Documentation is available at Checkbox.php

  1. <?php
  2. /**
  3.  * CNZ Framework
  4.  *
  5.  * A Framework for Creating and Using Complex Web Elements
  6.  *
  7.  * The purpose of this framework is to provide a library of high-level objects
  8.  * to facilitate common HTML coding tasks, such as menus, tables, and forms.
  9.  * The intent is to reduce repetitive HTML coding as much as possible, replacing
  10.  * it with a combination of configuration files and style sheets with
  11.  * standardized naming conventions.
  12.  *
  13.  * This framework is built on and requires the
  14.  * {@link http://framework.zend.com/ Zend Framework}.
  15.  *
  16.  * @category   Cnz
  17.  * @package    Cnz_Html
  18.  * @subpackage Form
  19.  *
  20.  * @author    Lyle Frost <lfrost@cnz.com>
  21.  * @copyright Copyright (c) 2006-2007 Citadel Network <{@link http://www.citadelnetwork.com/}>
  22.  * @filesource
  23.  * @license   http://www.citadelnetwork.com/license/cnzframework New BSD License
  24.  * @version   $Id: Checkbox.php 27 2007-07-19 18:47:54Z lfrost $
  25.  */
  26.  
  27. /**
  28.  * Required classes.
  29.  *
  30.  * @ignore
  31.  */
  32. Zend_Loader::loadClass('Cnz_Html_Form_Item');
  33.  
  34. /**
  35.  * HTML Form Checkbox class
  36.  *
  37.  * This class automates the creation and display of a checkbox.
  38.  *
  39.  * Example INI (defaults shown as comments):
  40.  * 
  41.  * <pre><samp>
  42.  * item.is_active.label  = Active
  43.  * item.is_active.type   = checkbox
  44.  * ;item.is_active.value = true
  45.  * </samp></pre>
  46.  *
  47.  * @category   Cnz
  48.  * @package    Cnz_Html
  49.  * @subpackage Form
  50.  */
  51. {
  52.     /**#@+ @var string */
  53.  
  54.     /** Value to use when checked. */
  55.     private    $value    'true';
  56.  
  57.     /**#@-*/
  58.  
  59.     /*====================================================================*/
  60.  
  61.     /**
  62.      * Option fields:
  63.      *   none
  64.      *
  65.      * Configuration fields:
  66.      *   value  Value when checked
  67.      *
  68.      * @param array       $options Options
  69.      * @param Zend_Config $config  Configuration
  70.      */
  71.     public function __construct(array $options array()Zend_Config $config NULL)
  72.     {
  73.         parent::__construct($options$config);
  74.         if (isset($config->value)) $this->value $config->value;
  75.         return;
  76.     }
  77.  
  78.     /**
  79.      * @param  string $style Value for outermost style attribute
  80.      * @return void 
  81.      */
  82.     public function display($style NULL)
  83.     {
  84.         $indent Cnz_Html::indentGenerate();
  85.  
  86.         echo $indent'<div class = "'$this->genStyles('label')'">' '&nbsp;' '</div>'"\n";
  87.         echo $indent'<div class = "'$this->genStyles('field')'">';
  88.         echo '<input';
  89.         if (!empty($this->initial&& $this->initial == 'checked')
  90.         {
  91.             echo ' checked = "checked"';
  92.         }
  93.         echo ' id = "'$this->genId()'" name = "'$this->name'" type = "checkbox"';
  94.         if (!empty($this->value)) echo ' value = "'$this->value'"';
  95.         echo '/>';
  96.         echo '<label for = "'$this->genId()'">'$this->label'</label>';
  97.         echo '</div>'"\n";
  98.  
  99.         return;
  100.     }
  101. }

Documentation generated on Thu, 19 Jul 2007 15:01:57 -0400 by phpDocumentor 1.4.0RC2