1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: namespace Pry\Form\Element;
14:
15: use Pry\Form\Field;
16:
17: 18: 19: 20: 21: 22: 23: 24:
25: class Textarea extends Field
26: {
27:
28: 29: 30: 31: 32: 33: 34:
35: public function __construct($nom, $form)
36: {
37: parent::__construct($nom, $form);
38: $this->attrs['name'] = $nom;
39: }
40:
41: 42: 43: 44: 45: 46: 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: 59: 60: 61: 62: 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: 75: 76: 77: 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:
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: ?>