Overview

Namespaces

  • None
  • PHP
  • Pry
    • Auth
      • Interfaces
    • Config
    • Controller
    • Date
    • Db
    • Feed
      • Abstracts
      • Writers
    • File
      • Decorator
    • Form
      • Element
    • Image
    • Log
      • Writer
    • Net
      • Exception
    • Session
    • Util
    • Validate
      • Validator
    • View

Classes

  • AutoCompleter
  • Checkbox
  • Colorpicker
  • Date
  • DatePicker
  • Email
  • File
  • Hidden
  • Html
  • Ip
  • Mac
  • Multi
  • NumericStepper
  • Password
  • Radio
  • Select
  • Slider
  • Submit
  • Text
  • Textarea
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * Pry Framework
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file LICENSE.txt.
 10:  * 
 11:  */
 12: 
 13: namespace Pry\Form\Element;
 14: 
 15: use Pry\Form\Field;
 16: 
 17: /**
 18:  * Element Textarea
 19:  * @category Pry
 20:  * @package Form
 21:  * @subpackage Form_Element
 22:  * @version 1.0.7 
 23:  * @author Olivier ROGER <oroger.fr>
 24:  */
 25: class Textarea extends Field
 26: {
 27: 
 28:     /**
 29:      * Constructeur
 30:      *
 31:      * @param string $nom
 32:      * @param Form_Form $form
 33:      * @access public
 34:      */
 35:     public function __construct($nom, $form)
 36:     {
 37:         parent::__construct($nom, $form);
 38:         $this->attrs['name'] = $nom;
 39:     }
 40: 
 41:     /**
 42:      * Défini le nombre de colonne
 43:      *
 44:      * @param int $val
 45:      * @access public
 46:      * @return Form_Element_Textarea
 47:      */
 48:     public function cols($val)
 49:     {
 50:         if (ctype_digit((string) $val) && $val > 0)
 51:             $this->attrs['cols'] = $val;
 52:         else
 53:             unset($this->attrs['cols']);
 54:         return $this;
 55:     }
 56: 
 57:     /**
 58:      * Défini le nombre de ligne
 59:      *
 60:      * @param int $val
 61:      * @access public
 62:      * @return Form_Element_Textarea
 63:      */
 64:     public function rows($val)
 65:     {
 66:         if (ctype_digit((string) $val) && $val > 0)
 67:             $this->attrs['rows'] = $val;
 68:         else
 69:             unset($this->attrs['rows']);
 70:         return $this;
 71:     }
 72: 
 73:     /**
 74:      * Ecrit l'objet
 75:      *
 76:      * @access public
 77:      * @return string
 78:      */
 79:     public function __toString()
 80:     {
 81:         $css   = $this->cssClass();
 82:         $label = '';
 83:         if (!empty($this->label))
 84:         {
 85:             $label     = "\t" . '<label for="' . $this->attrs['id'] . '" class="' . $this->cssLabel . '">' . $this->label . '</label>' . "\n";
 86:             if ($this->labelNewLine)
 87:                 $label.="\t" . '<br />' . "\n";
 88:         }
 89:         $attributs = $this->attrsToString();
 90:         //Posted value ou value par défaut
 91:         $value     = $this->form->getPostedvalue($this->attrs['name']);
 92:         if (empty($value))
 93:             $value     = $this->value;
 94: 
 95:         $error = '';
 96:         if (!is_null($this->errorMsg))
 97:         {
 98:             $error = '<span class="' . $this->errorClass . '">' . $this->errorMsg . '</span><br />';
 99:         }
100: 
101:         $field = "\t" . '<textarea ' . $css . ' ' . $attributs . '>' . htmlspecialchars($value) . '</textarea>' . "\n";
102:         if (!empty($this->info))
103:             $field.="\t" . '<img src="' . $this->imgInfo . '" id="' . $this->attrs['name'] . '_tooltip" class="form_tooltip" title="' . $this->info . '" alt="" style="cursor:help;" />';
104:         if ($this->fieldNewLine)
105:             $field.='<br />';
106:         return $label . $field . $error;
107:     }
108: 
109: }
110: 
111: ?>
Pry API documentation generated by ApiGen 2.8.0