Orion PHP  0.11.12
The PHP5.3 framework
text.php
Go to the documentation of this file.
00001 <?php
00002 namespace Orion\Core\Model;
00003 
00004 
00005 class Text extends Field
00006 {
00007     protected $length;
00008 
00009     public function __construct($bind='text', $label='Text', $length=1000, $required=false)
00010     {
00011         $this->type = 'text';
00012         $this->bind = $bind;
00013         $this->label = $label;
00014         $this->length = $length;
00015         $this->required = $required;
00016     }
00017 
00018     public function validate($value)
00019         {
00020                 if($this->length != null && strlen($value) > $this->length)
00021                         return false;
00022                 else
00023                         return true;
00024         }
00025 
00026     public function prepare($value)
00027     {
00028         return "'".$value."'";
00029     }
00030 
00031     public function toHtml($XHTML=true)
00032     {
00033         if($XHTML)
00034             $tag = ' /';
00035         else
00036             $tag = '';
00037 
00038         return '<div class="form-row"><label for="'.$this->bind.'">'.$this->label.'</label><div class="form-container"><textarea name="'.$this->bind.'" class="form-textarea">'.$this->value.'</textarea></div></div>';
00039     }
00040 }
00041 
00042 ?>