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:  * Input de type Text
 15:  * @category Pry
 16:  * @package Form
 17:  * @subpackage Form_Element
 18:  * @version 1.0.6 
 19:  * @author Olivier ROGER <oroger.fr>
 20:  */
 21: class Form_Element_Text extends Form_Input
 22: {
 23:     /**
 24:      * Taille minimal
 25:      *
 26:      * @var int
 27:      * @access protected
 28:      */
 29:     protected $minLength;
 30:     
 31:     /**
 32:      * Constructeur
 33:      *
 34:      * @param string $nom
 35:      * @param Form_Form $form
 36:      * @access public
 37:      */
 38:     public function __construct($nom,$form)
 39:     {
 40:         parent::__construct($nom,$form);
 41:         if(!isset($this->attrs['type']))
 42:             $this->setAttributes('type','text');
 43:         $this->minLength = 0;
 44:     }
 45:     
 46:     /**
 47:      * Défini une taille minimal pour le contenu
 48:      *
 49:      * @param int $taille
 50:      * @access public
 51:      * @return Form_Element_Text
 52:      */
 53:     public function minLength($taille)
 54:     {
 55:         if(ctype_digit((string)$taille) && $taille>=0)
 56:             $this->minLength = $taille;
 57:         return $this;
 58:     }
 59:     
 60:     /**
 61:      * Vérifie que la valeur est valide
 62:      *
 63:      * @param string $value
 64:      * @return boolean
 65:      */
 66:     public function isValid($value)
 67:     {
 68:         if(parent::isValid($value))
 69:         {
 70:             if(!$this->required && empty($value))
 71:                 return true;
 72:             if(!$this->minLength == 0)
 73:                 $carac = $this->minLength -1;
 74:             else
 75:                 return true;
 76:             
 77:             if(isset($value[$carac]))
 78:                 return true;
 79:             else
 80:                 $this->errorMsg = Form_Error::TOOSHORT.$this->minLength;
 81:         }
 82:         return false;
 83:     }
 84:     /**
 85:      * Ecris l'élément avec toutes ses options
 86:      *
 87:      * @param array $array
 88:      * @return string
 89:      */
 90:     public function __toString()
 91:     {
 92:         
 93:         $css = $this->cssClass();
 94:         $label = '';
 95:         if(!empty($this->label))
 96:         {
 97:             $label = "\t".'<label for="'.$this->attrs['id'].'" class="'.$this->cssLabel.'">'.$this->label.'</label>'."\n";
 98:             if($this->labelNewLine)
 99:                 $label.="\t".'<br />'."\n";
100:         }
101:         $attributs = $this->attrsToString();
102:         //Posted value ou value par défaut
103:         $value = $this->form->getPostedvalue($this->attrs['name']);
104:         if(empty($value))
105:             $value = $this->value;
106:             
107:         $field = "\t".'<input '.$css.' value="'.htmlspecialchars($value).'" '.$attributs.' />'."\n";
108:         
109:         $error='';
110:         if(!is_null($this->errorMsg))
111:         {
112:             $error='<span class="'.$this->errorClass.'">'.$this->errorMsg.'</span><br />';
113:         }
114:         if(!empty($this->info))
115:             $field.="\t".'<img src="'.$this->imgInfo.'" id="'.$this->attrs['name'].'_tooltip" class="form_tooltip" title="'.$this->info.'" alt="" style="cursor:help;" />';
116:         if($this->fieldNewLine)
117:             $field.="\t".'<br />'."\n";
118:         return $label.$field.$error;
119:     }
120: }
121:  ?>
Pry Framework API documentation generated by ApiGen 2.6.1