Orion PHP  0.11.12
The PHP5.3 framework
bool.php
Go to the documentation of this file.
00001 <?php
00002 namespace Orion\Core\Model;
00003 
00004 
00005 class Bool extends Field
00006 {
00007     public function __construct($bind='bool', $label='Boolean', $required=false)
00008     {
00009         $this->type = 'bool';
00010         $this->bind = $bind;
00011         $this->label = $label;
00012         $this->required = $required;
00013     }
00014     
00015     public function isEmptyValue($value)
00016     {
00017         return false;
00018     }
00019     
00020     public function prepare($value)
00021     {
00022         return empty($value) ? 0 : 1;
00023     }
00024 
00025     public function toHtml($XHTML=true)
00026     {
00027         if($XHTML)
00028             $tag = ' /';
00029         else
00030             $tag = '';
00031 
00032         return '<div class="form-row"><label for="'.$this->bind.'">'.$this->label.'</label><div class="form-container"><div class="form-element"><input name="'.$this->bind.'" type="checkbox" class="form-checkbox" value="1"'. ($this->value ? ' checked="checked"' : '' ) .$tag.'></div></div></div>';
00033     }
00034 }
00035 
00036 ?>