1 | 2 | simandl | <?php |
2 | | | |
3 | | | namespace Phem\Libraries\Forms\Model; |
4 | | | |
5 | | | /** |
6 | | | * @Entity(readOnly=true) @Table(name="povruc_form_field") |
7 | | | * |
8 | | | */ |
9 | | | class FormField |
10 | | | { |
11 | | | |
12 | | | /** @Id @Column(type="integer") */ |
13 | | | protected $id; |
14 | | | |
15 | | | /** |
16 | | | * @ManyToOne(targetEntity="FormGroup",cascade={"all"}) |
17 | | | * @JoinColumn(name="group", referencedColumnName="id") |
18 | | | */ |
19 | | | protected $group; |
20 | | | |
21 | | | /** @Column(type="string") */ |
22 | | | protected $name; |
23 | | | |
24 | | | /** @Column(type="string") */ |
25 | | | protected $caption; |
26 | | | |
27 | | | /** @Column(type="string") */ |
28 | | | protected $type; |
29 | | | |
30 | | | /** @Column(type="string") */ |
31 | | | protected $note; |
32 | | | |
33 | | | /** @Column(type="boolean") */ |
34 | | | protected $required; |
35 | | | protected $readOnly; |
36 | | | |
37 | | | /** @Column(type="boolean") */ |
38 | | | protected $enabled; |
39 | | | |
40 | | | /** @Column(type="integer") */ |
41 | | | protected $order; |
42 | | | protected $options; |
43 | | | protected $value; |
44 | | | |
45 | | | /** |
46 | | | * |
47 | | | * @OneToMany(targetEntity="FormFieldValidation", mappedBy="field",cascade={"all"}) |
48 | | | */ |
49 | | | protected $rules; //set of rules for validation |
50 | | | /** |
51 | | | * |
52 | | | * @OneToMany(targetEntity="FormFieldCondition", mappedBy="sourceField",cascade={"all"}) |
53 | | | */ |
54 | | | protected $triggers; //set of conditions which are based on value of this field (where this is trigger) |
55 | | | |
56 | | | /** |
57 | | | * |
58 | | | * @OneToMany(targetEntity="FormFieldCondition", mappedBy="targetField",cascade={"all"}) |
59 | | | */ |
60 | | | protected $dependencies; //set of conditions which are based on value of this field (where this is trigger) |
61 | | | |
62 | | | public function getId() |
63 | | | { |
64 | | | return $this->id; |
65 | | | } |
66 | | | |
67 | | | public function setId($id) |
68 | | | { |
69 | | | $this->id = $id; |
70 | | | } |
71 | | | |
72 | | | public function getDependencies() |
73 | | | { |
74 | | | return $this->dependencies; |
75 | | | } |
76 | | | |
77 | | | public function setDependencies($dependencies) |
78 | | | { |
79 | | | $this->dependencies = $dependencies; |
80 | | | } |
81 | | | |
82 | | | public function getGroup() |
83 | | | { |
84 | | | return $this->group; |
85 | | | } |
86 | | | |
87 | | | public function setGroup($group) |
88 | | | { |
89 | | | $this->group = $group; |
90 | | | } |
91 | | | |
92 | | | public function getName() |
93 | | | { |
94 | | | return $this->name; |
95 | | | } |
96 | | | |
97 | | | public function setName($name) |
98 | | | { |
99 | | | $this->name = $name; |
100 | | | } |
101 | | | |
102 | | | public function getCaption() |
103 | | | { |
104 | | | return $this->caption; |
105 | | | } |
106 | | | |
107 | | | public function setCaption($caption) |
108 | | | { |
109 | | | $this->caption = $caption; |
110 | | | } |
111 | | | |
112 | | | public function getType() |
113 | | | { |
114 | | | return $this->type; |
115 | | | } |
116 | | | |
117 | | | public function setType($type) |
118 | | | { |
119 | | | $this->type = $type; |
120 | | | } |
121 | | | |
122 | | | public function getNote() |
123 | | | { |
124 | | | return $this->note; |
125 | | | } |
126 | | | |
127 | | | public function setNote($note) |
128 | | | { |
129 | | | $this->note = $note; |
130 | | | } |
131 | | | |
132 | | | public function getRequired() |
133 | | | { |
134 | | | return $this->required; |
135 | | | } |
136 | | | |
137 | | | public function setRequired($required) |
138 | | | { |
139 | | | $this->required = $required; |
140 | | | } |
141 | | | |
142 | | | public function getReadOnly() |
143 | | | { |
144 | | | return $this->readOnly; |
145 | | | } |
146 | | | |
147 | | | public function setReadOnly($readOnly) |
148 | | | { |
149 | | | $this->readOnly = $readOnly; |
150 | | | } |
151 | | | |
152 | | | public function getEnabled() |
153 | | | { |
154 | | | return $this->enabled; |
155 | | | } |
156 | | | |
157 | | | public function setEnabled($enabled) |
158 | | | { |
159 | | | $this->enabled = $enabled; |
160 | | | } |
161 | | | |
162 | | | public function getOrder() |
163 | | | { |
164 | | | return $this->order; |
165 | | | } |
166 | | | |
167 | | | public function setOrder($order) |
168 | | | { |
169 | | | $this->order = $order; |
170 | | | } |
171 | | | |
172 | | | public function getRules() |
173 | | | { |
174 | | | return $this->rules; |
175 | | | } |
176 | | | |
177 | | | public function setRules($rules) |
178 | | | { |
179 | | | $this->rules = $rules; |
180 | | | } |
181 | | | |
182 | | | public function getTriggers() |
183 | | | { |
184 | | | return $this->triggers; |
185 | | | } |
186 | | | |
187 | | | public function setTriggers($triggers) |
188 | | | { |
189 | | | $this->triggers = $triggers; |
190 | | | } |
191 | | | |
192 | | | public function isTrigger() |
193 | | | { |
194 | | | return (count($this->triggers) > 0 ); |
195 | | | } |
196 | | | |
197 | | | public |
198 | | | function getValue() |
199 | | | { |
200 | | | return $this->value; |
201 | | | } |
202 | | | |
203 | | | public |
204 | | | function setValue($value) |
205 | | | { |
206 | | | $this->value = $value; |
207 | | | } |
208 | | | |
209 | | | public function getOptions() |
210 | | | { |
211 | | | return $this->options; |
212 | | | } |
213 | | | |
214 | | | public function setOptions($options) |
215 | | | { |
216 | | | $this->options = $options; |
217 | | | } |
218 | | | |
219 | | | public function isTriggerErase() |
220 | | | { |
221 | | | $ret = false; |
222 | | | foreach ($this->triggers as $t) |
223 | | | { |
224 | | | if ($t->getAction() == "erase") |
225 | | | { |
226 | | | $ret = true; |
227 | | | } |
228 | | | } |
229 | | | return $ret; |
230 | | | } |
231 | | | |
232 | | | } |