1: <?php
2:
3: namespace Zippy\Html\Form;
4:
5: use Zippy\Html\HtmlComponent;
6: use Zippy\Interfaces\SubmitDataRequest;
7: use Zippy\Interfaces\Binding;
8:
9: /**
10: * Базовый класс для компонентов, способных принимать данные с формы
11: */
12: abstract class HtmlFormDataElement extends HtmlComponent implements SubmitDataRequest
13: {
14: protected $value = null;
15:
16: /**
17: * Устанавливает значение данных объекта
18: * @param mixed Объект данных или PropertyBinding
19: */
20: public function setValue($value) {
21: if ($this->value instanceof Binding && !($value instanceof Binding)) {
22: $this->value->setValue($value);
23: } else {
24: $this->value = $value;
25: }
26: }
27:
28: /**
29: * Возвращает значение данных объекта
30: */
31: public function getValue() {
32: if ($this->value instanceof Binding) {
33: return $this->value->getValue();
34: } else {
35: return $this->value;
36: }
37: }
38:
39: }
40: