1 | <?php |
||
24 | abstract class Field implements FieldInterface |
||
25 | { |
||
26 | /** |
||
27 | * @var string field name |
||
28 | */ |
||
29 | protected $name; |
||
30 | |||
31 | /** |
||
32 | * @var string field label (for labels associated with this input field on a form) |
||
33 | */ |
||
34 | protected $label; |
||
35 | |||
36 | /** |
||
37 | * @var string field input placeholder value (for input placeholders on forms) |
||
38 | */ |
||
39 | protected $placeholder; |
||
40 | |||
41 | /** |
||
42 | * @var bool true, if this field is required |
||
43 | */ |
||
44 | protected $required = false; |
||
45 | |||
46 | /** |
||
47 | * @param string $name field name |
||
48 | */ |
||
49 | 57 | public function __construct($name) |
|
53 | |||
54 | 44 | public function getName() |
|
58 | |||
59 | 17 | public function getLabel() |
|
63 | |||
64 | 12 | public function getPlaceholder() |
|
68 | |||
69 | 24 | public function isRequired() |
|
73 | |||
74 | public function getValue(InputModel $model) |
||
78 | |||
79 | 10 | public function createValidators() |
|
85 | |||
86 | /** |
||
87 | * @param string $label display label |
||
88 | */ |
||
89 | 18 | public function setLabel($label) |
|
93 | |||
94 | /** |
||
95 | * @param string $placeholder placeholder label |
||
96 | */ |
||
97 | 1 | public function setPlaceholder($placeholder) |
|
101 | |||
102 | /** |
||
103 | * @param bool $required TRUE, if input is required for this Field; FALSE, if it's optional |
||
104 | */ |
||
105 | 15 | public function setRequired($required = true) |
|
109 | |||
110 | /** |
||
111 | * @param InputModel $model |
||
112 | * @param string|null $value |
||
113 | * |
||
114 | * @return void |
||
115 | * |
||
116 | * @throws InvalidArgumentException if the given value is unacceptable. |
||
117 | */ |
||
118 | 8 | public function setValue(InputModel $model, $value) |
|
128 | } |
||
129 |