-
Notifications
You must be signed in to change notification settings - Fork 0
/
Textarea.php
111 lines (84 loc) · 2.45 KB
/
Textarea.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
namespace Onimla\HTML;
use Onimla\HTML\Polymorphism\UserInput;
class Textarea extends Element implements UserInput {
use Traits\Name;
public function __construct($name, $value = FALSE, $rows = FALSE, $attr = NULL, $children = FALSE) {
parent::__construct('textarea', $attr, $children);
$this->name($name);
$this->value($value);
$this->rows($rows);
$this->selfClose(FALSE);
}
public function disabled() {
return $this->isDisabled();
}
public function disable() {
$this->setDisabled();
return $this;
}
public function enable() {
$this->unsetDisabled();
return $this;
}
public function rows($value = FALSE) {
return $this->attr('rows', $value, 'int');
}
/**
* A text area can hold an unlimited number of characters
* @see http://www.w3schools.com/tags/tag_textarea.asp
* @param string $value multi-line text (calls <code>Element::text()</code>)
* @return Textarea|string method chaining or the value
*/
public function value($value = FALSE) {
return $this->text(...func_get_args());
}
public function isDisabled() {
return (bool) $this->attr(__FUNCTION__);
}
public function isNotReadOnly() {
return !$this->isReadOnly();
}
public function isNotRequired() {
return !$this->isRequired();
}
public function isReadOnly() {
return (bool) $this->attr('readonly');
}
public function isRequired() {
return (bool) $this->attr('required');
}
public function isValueSet() {
return strlen($this->text()) > 0;
}
public function readOnly() {
return $this->isReadOnly();
}
public function required() {
return $this->isRequired();
}
public function setDisabled() {
$this->attr('disabled', 'disabled');
}
public function setReadOnly() {
$this->attr('readonly', 'readonly');
}
public function setRequired() {
$this->attr('required', 'required');
}
public function type($value = FALSE) {
if ($value === FALSE) {
return 'textarea';
}
return $this;
}
public function unsetDisabled() {
$this->removeAttr('disabled');
}
public function unsetReadOnly() {
$this->removeAttr('readonly');
}
public function unsetRequired() {
$this->removeAttr('required');
}
}