Overview

Packages

  • Auth
  • Config
  • Controller
  • Date
  • Db
  • Feed
    • Abstract
    • Writers
  • File
    • Decorator
  • Form
    • Element
  • Image
  • Log
    • Writer
  • Net
    • Exception
  • None
  • PHP
  • PHPMailer
  • Session
  • Util
  • Validate
    • Validator
  • Zend
    • Registry

Classes

  • Form_Element_AutoCompleter
  • Form_Element_Checkbox
  • Form_Element_Colorpicker
  • Form_Element_Date
  • Form_Element_DatePicker
  • Form_Element_Email
  • Form_Element_File
  • Form_Element_Hidden
  • Form_Element_Html
  • Form_Element_Ip
  • Form_Element_Mac
  • Form_Element_Multi
  • Form_Element_NumericStepper
  • Form_Element_Password
  • Form_Element_Radio
  • Form_Element_Select
  • Form_Element_Slider
  • Form_Element_Submit
  • Form_Element_Text
  • Form_Element_Textarea
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Pry Framework
  4:  *
  5:  * LICENSE
  6:  *
  7:  * This source file is subject to the new BSD license that is bundled
  8:  * with this package in the file LICENSE.txt.
  9:  * 
 10:  * @version $Revision: 276 $
 11:  */
 12: 
 13: /**
 14:  * Elément checkbox
 15:  * 
 16:  * @category Pry
 17:  * @package Form
 18:  * @subpackage Form_Element
 19:  * @version 1.1.2 
 20:  * @author Olivier ROGER <oroger.fr>  
 21:  *
 22:  */
 23: class Form_Element_Checkbox extends Form_Input
 24: {
 25:     /**
 26:      * Case cochée
 27:      *
 28:      * @var boolean
 29:      * @access private
 30:      */
 31:     private $checked;
 32:     
 33:     /**
 34:      * Constructeur. Par défaut case non cochée
 35:      *
 36:      * @param string $nom
 37:      * @param Form_Form $form
 38:      * @access public
 39:      */
 40:     public function __construct($nom,$form)
 41:     {
 42:         parent::__construct($nom,$form);
 43:         $this->attrs['type'] = 'checkbox';
 44:         $this->checked = false;
 45:     }
 46:     
 47:     /**
 48:      * Défini si la case est cochée ou non
 49:      *
 50:      * @param boolean $bool
 51:      * @access public
 52:      * @return Form_Element_Checkbox
 53:      */
 54:     public function checked($bool = true)
 55:     {
 56:         $this->checked = $bool;
 57:         return $this;
 58:     }
 59:     
 60:     /**
 61:      * Ecrit l'objet
 62:      *
 63:      * @access public
 64:      * @return ustring
 65:      */
 66:     public function __toString()
 67:     {
 68:         $this->cssClass();
 69:         $label  = '';
 70:         $css    = '';
 71:         if(!empty($this->label))
 72:         {
 73:             $label = "\t".'<span class="'.$this->cssLabel.'">'.$this->label.'</span>'."\n";
 74:             if(!empty($this->info))
 75:             $label.="\t".'<img src="'.$this->imgInfo.'" id="'.$this->attrs['name'].'_tooltip" class="form_tooltip" title="'.$this->info.'" alt="" style="cursor:help;" />';
 76:             if($this->labelNewLine)
 77:                 $label.="\t".'<br />'."\n";
 78:         }
 79:         $error = '';
 80:         if(!is_null($this->errorMsg))
 81:         {
 82:             $error='<span class="'.$this->errorClass.'">'.$this->errorMsg.'</span><br />';
 83:         }
 84:         
 85:         //Posted value ou value par défaut
 86:         $value = $this->form->getPostedvalue($this->attrs['name']);
 87:         if(empty($value))
 88:         {
 89:             $value = $this->value;
 90:             if(!$this->checked)
 91:                 unset($this->attrs['checked']);
 92:             else
 93:                 $this->attrs['checked'] = 'checked';
 94:         }
 95:         elseif(!empty($value))
 96:         {
 97:             $this->attrs['checked'] = 'checked';
 98:         }
 99:         elseif($this->value == $value || $this->checked)
100:             $this->attrs['checked'] = 'checked';
101:         
102:         $attributs = $this->attrsToString();
103:             
104:         $field = "\t".'<input '.$css.' '.$attributs.' />'."\n";
105:         
106:         return $field.$label.$error;
107:     }
108: }
109:  ?>
Pry Framework API documentation generated by ApiGen 2.6.1