1 | <?php |
||
13 | class BaseElement extends \Fiv\Form\Element\Html { |
||
14 | |||
15 | /** |
||
16 | * @var null|boolean |
||
17 | */ |
||
18 | protected $validationResult = null; |
||
19 | |||
20 | /** |
||
21 | * @var \Fiv\Form\Validator\Base[] |
||
22 | */ |
||
23 | protected $validators = []; |
||
24 | |||
25 | /** |
||
26 | * @var \Fiv\Form\Filter\FilterInterface[] |
||
27 | */ |
||
28 | protected $filters = []; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $text = ''; |
||
34 | |||
35 | /** |
||
36 | * @var null|string |
||
37 | */ |
||
38 | protected $value = null; |
||
39 | |||
40 | |||
41 | /** |
||
42 | * Attach validator to current element |
||
43 | * |
||
44 | * @deprecated |
||
45 | * @see addValidators |
||
46 | * |
||
47 | * @param \Fiv\Form\Validator\ValidatorInterface[]|\Fiv\Form\Validator\ValidatorInterface $validator |
||
48 | * @throws \Exception |
||
49 | * @return $this |
||
50 | */ |
||
51 | public function addValidator($validator) { |
||
59 | |||
60 | |||
61 | /** |
||
62 | * Attach validators to current element |
||
63 | * |
||
64 | * @param ValidatorInterface[] $validators |
||
65 | * @return $this |
||
66 | * @throws \Exception |
||
67 | */ |
||
68 | 6 | public function addValidators(array $validators) { |
|
80 | |||
81 | |||
82 | /** |
||
83 | * @return \Fiv\Form\Validator\Base[] |
||
84 | */ |
||
85 | 8 | public function getValidators() { |
|
88 | |||
89 | |||
90 | /** |
||
91 | * @deprecated |
||
92 | * @see addFilters |
||
93 | * |
||
94 | * @param \Fiv\Form\Filter\FilterInterface|\Fiv\Form\Filter\FilterInterface[] $filter |
||
95 | * @throws \Exception |
||
96 | * @return $this |
||
97 | */ |
||
98 | public function addFilter($filter) { |
||
106 | |||
107 | |||
108 | /** |
||
109 | * Attach filters to current element |
||
110 | * |
||
111 | * @param FilterInterface[] $filters |
||
112 | * @return $this |
||
113 | * @throws \Exception |
||
114 | */ |
||
115 | 3 | public function addFilters(array $filters) { |
|
125 | |||
126 | |||
127 | /** |
||
128 | * @return \Fiv\Form\Filter\FilterInterface[] |
||
129 | */ |
||
130 | 16 | public function getFilters() { |
|
133 | |||
134 | |||
135 | /** |
||
136 | * Alias of setAttribute('value', $value) |
||
137 | * |
||
138 | * @param $value |
||
139 | * @return $this |
||
140 | */ |
||
141 | 2 | public function setValue($value) { |
|
145 | |||
146 | |||
147 | /** |
||
148 | * @return string |
||
149 | */ |
||
150 | 14 | public function getValue() { |
|
153 | |||
154 | |||
155 | /** |
||
156 | * @inheritdoc |
||
157 | */ |
||
158 | 18 | public function setAttribute($name, $value) { |
|
174 | |||
175 | |||
176 | /** |
||
177 | * Return true if element is valid |
||
178 | * @return boolean |
||
179 | */ |
||
180 | 8 | public function validate() { |
|
197 | |||
198 | |||
199 | /** |
||
200 | * @return array |
||
201 | */ |
||
202 | public function getValidatorsErrors() { |
||
210 | |||
211 | |||
212 | /** |
||
213 | * @inheritdoc |
||
214 | */ |
||
215 | 3 | public function render() { |
|
220 | |||
221 | |||
222 | /** |
||
223 | * @deprecated |
||
224 | * @see addValidators |
||
225 | * @return $this |
||
226 | */ |
||
227 | public function required() { |
||
231 | |||
232 | |||
233 | /** |
||
234 | * @param string $text |
||
235 | * @return $this |
||
236 | */ |
||
237 | 10 | public function setText($text) { |
|
241 | |||
242 | |||
243 | /** |
||
244 | * @return mixed |
||
245 | */ |
||
246 | public function getText() { |
||
249 | |||
250 | |||
251 | /** |
||
252 | * @param string $name |
||
253 | * @return $this |
||
254 | */ |
||
255 | 17 | public function setName($name) { |
|
259 | |||
260 | |||
261 | /** |
||
262 | * @return null|string |
||
263 | */ |
||
264 | 16 | public function getName() { |
|
267 | |||
268 | |||
269 | /** |
||
270 | * @param string $class |
||
271 | * @return $this |
||
272 | */ |
||
273 | 1 | public function setClass($class) { |
|
277 | |||
278 | |||
279 | /** |
||
280 | * @return null|string |
||
281 | */ |
||
282 | 1 | public function getClass() { |
|
285 | |||
286 | |||
287 | /** |
||
288 | * @param string $id |
||
289 | * @return $this |
||
290 | */ |
||
291 | public function setId($id) { |
||
295 | |||
296 | |||
297 | /** |
||
298 | * @return null|string |
||
299 | */ |
||
300 | public function getId() { |
||
303 | |||
304 | } |