Orion PHP  0.11.12
The PHP5.3 framework
numeric.php
Go to the documentation of this file.
00001 <?php
00002 namespace Orion\Core\Model;
00003 
00004 
00005 class Numeric extends Field
00006 {
00007     /**
00008      * Integer model field
00009      * @param string $bind
00010      * @param string $label
00011      * @param boolean $required
00012      * @param boolean $primary
00013      */
00014     public function __construct($bind='number', $label='Number', $required=false, $primary=false)
00015     {
00016         $this->type = 'numeric';
00017         $this->bind = $bind;
00018         $this->label = $label;
00019         $this->required = $required;
00020         $this->primary = $primary;
00021     }
00022     
00023     public function validate( $value )
00024     {
00025         return is_numeric( $value );
00026     }
00027 
00028     public function toHtml($XHTML=true)
00029     {
00030         if($XHTML)
00031             $tag = ' /';
00032         else
00033             $tag = '';
00034 
00035         return '<div class="form-row"><label for="'.$this->bind.'">'.$this->label.'</label><div class="form-container"><input name="'.$this->bind.'" type="text" class="form-text" value="'.$this->value.'"'.$tag.'></div></div>';
00036     }
00037 }
00038 
00039 ?>