1
|
|
|
<?php /** MicroForm */ |
2
|
|
|
|
3
|
|
|
namespace Micro\Form; |
4
|
|
|
|
5
|
|
|
use Micro\Web\Html; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Form class file. |
9
|
|
|
* |
10
|
|
|
* @author Oleg Lunegov <[email protected]> |
11
|
|
|
* @link https://github.com/lugnsk/micro |
12
|
|
|
* @copyright Copyright © 2013 Oleg Lunegov |
13
|
|
|
* @license /LICENSE |
14
|
|
|
* @package Micro |
15
|
|
|
* @subpackage Form |
16
|
|
|
* @version 1.0 |
17
|
|
|
* @since 1.0 |
18
|
|
|
*/ |
19
|
|
|
class Form |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Render label tag |
23
|
|
|
* |
24
|
|
|
* @access public |
25
|
|
|
* |
26
|
|
|
* @param IFormModel $model model |
27
|
|
|
* @param string $property model property |
28
|
|
|
* @param array $options attributes array |
29
|
|
|
* |
30
|
|
|
* @return string |
31
|
|
|
*/ |
32
|
|
|
public function label(IFormModel $model, $property, array $options = []) |
33
|
|
|
{ |
34
|
|
|
$element = $this->getField($model, $property); |
35
|
|
|
|
36
|
|
|
return Html::label($model->getLabel($property), $element['id'], $options); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Get model field data |
41
|
|
|
* |
42
|
|
|
* @access private |
43
|
|
|
* |
44
|
|
|
* @param IFormModel $model model |
45
|
|
|
* @param string $property model property |
46
|
|
|
* |
47
|
|
|
* @return array |
48
|
|
|
*/ |
49
|
|
|
protected function getField(IFormModel $model, $property) |
50
|
|
|
{ |
51
|
|
|
$cl = get_class($model); |
52
|
|
|
$smallName = substr($cl, strrpos($cl, '\\') + 1); |
53
|
|
|
|
54
|
|
|
return [ |
55
|
|
|
'id' => $smallName . '_' . $property, |
56
|
|
|
'name' => $smallName . '[' . $property . ']', |
57
|
|
|
'value' => (property_exists($model, $property)) ? $model->$property : null |
58
|
|
|
]; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Render hidden field tag |
63
|
|
|
* |
64
|
|
|
* @access public |
65
|
|
|
* |
66
|
|
|
* @param IFormModel $model model |
67
|
|
|
* @param string $property model property |
68
|
|
|
* @param array $options attributes array |
69
|
|
|
* |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
public function hiddenField(IFormModel $model, $property, array $options = []) |
73
|
|
|
{ |
74
|
|
|
$element = $this->getField($model, $property); |
75
|
|
|
|
76
|
|
|
return Html::hiddenField($element['name'], $element['value'], $options); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Render button field tag |
81
|
|
|
* |
82
|
|
|
* @access public |
83
|
|
|
* |
84
|
|
|
* @param IFormModel $model model |
85
|
|
|
* @param string $property model property |
86
|
|
|
* @param array $options attributes array |
87
|
|
|
* |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
View Code Duplication |
public function buttonField(IFormModel $model, $property, array $options = []) |
|
|
|
|
91
|
|
|
{ |
92
|
|
|
$element = $this->getField($model, $property); |
93
|
|
|
$options['id'] = $element['id']; |
94
|
|
|
|
95
|
|
|
return Html::buttonField($element['name'], $element['value'], $options); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Render radio field tag |
100
|
|
|
* |
101
|
|
|
* @access public |
102
|
|
|
* |
103
|
|
|
* @param IFormModel $model model |
104
|
|
|
* @param string $property model property |
105
|
|
|
* @param array $options attributes array |
106
|
|
|
* |
107
|
|
|
* @return string |
108
|
|
|
*/ |
109
|
|
View Code Duplication |
public function radioField(IFormModel $model, $property, array $options = []) |
|
|
|
|
110
|
|
|
{ |
111
|
|
|
$element = $this->getField($model, $property); |
112
|
|
|
$options['id'] = $element['id']; |
113
|
|
|
|
114
|
|
|
return Html::radioField($element['name'], $element['value'], $options); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Render text field row |
119
|
|
|
* |
120
|
|
|
* @access public |
121
|
|
|
* |
122
|
|
|
* @param IFormModel $model model |
123
|
|
|
* @param string $property model property |
124
|
|
|
* @param array $options attribute array |
125
|
|
|
* |
126
|
|
|
* @return string |
127
|
|
|
*/ |
128
|
|
View Code Duplication |
public function textFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
129
|
|
|
{ |
130
|
|
|
$element = $this->getField($model, $property); |
131
|
|
|
$options['id'] = $element['id']; |
132
|
|
|
|
133
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
134
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
135
|
|
|
$this->textField($model, $property, $options) . |
136
|
|
|
Html::closeTag('div'); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
// Fields |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Get block from options |
143
|
|
|
* |
144
|
|
|
* @access protected |
145
|
|
|
* |
146
|
|
|
* @param string $name Block name |
147
|
|
|
* @param array $options Options array |
148
|
|
|
* |
149
|
|
|
* @return array |
150
|
|
|
*/ |
151
|
|
|
protected function getBlock($name, array &$options) |
152
|
|
|
{ |
153
|
|
|
$block = []; |
154
|
|
|
if (!empty($options[$name])) { |
155
|
|
|
$block = $options[$name]; |
156
|
|
|
unset($options[$name]); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
return $block; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Render text field tag |
164
|
|
|
* |
165
|
|
|
* @access public |
166
|
|
|
* |
167
|
|
|
* @param IFormModel $model model |
168
|
|
|
* @param string $property model property |
169
|
|
|
* @param array $options attributes array |
170
|
|
|
* |
171
|
|
|
* @return string |
172
|
|
|
*/ |
173
|
|
View Code Duplication |
public function textField(IFormModel $model, $property, array $options = []) |
|
|
|
|
174
|
|
|
{ |
175
|
|
|
$element = $this->getField($model, $property); |
176
|
|
|
$options['id'] = $element['id']; |
177
|
|
|
|
178
|
|
|
return Html::textField($element['name'], $element['value'], $options); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Render file field row |
183
|
|
|
* |
184
|
|
|
* @access public |
185
|
|
|
* |
186
|
|
|
* @param IFormModel $model model |
187
|
|
|
* @param string $property model property |
188
|
|
|
* @param array $options attribute array |
189
|
|
|
* |
190
|
|
|
* @return string |
191
|
|
|
*/ |
192
|
|
View Code Duplication |
public function fileFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
193
|
|
|
{ |
194
|
|
|
$element = $this->getField($model, $property); |
195
|
|
|
$options['id'] = $element['id']; |
196
|
|
|
|
197
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
198
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
199
|
|
|
$this->fileField($model, $property, $options) . |
200
|
|
|
Html::closeTag('div'); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Render file field tag |
205
|
|
|
* |
206
|
|
|
* @access public |
207
|
|
|
* |
208
|
|
|
* @param IFormModel $model model |
209
|
|
|
* @param string $property model property |
210
|
|
|
* @param array $options attributes array |
211
|
|
|
* |
212
|
|
|
* @return string |
213
|
|
|
*/ |
214
|
|
View Code Duplication |
public function fileField(IFormModel $model, $property, array $options = []) |
|
|
|
|
215
|
|
|
{ |
216
|
|
|
$element = $this->getField($model, $property); |
217
|
|
|
$options['id'] = $element['id']; |
218
|
|
|
|
219
|
|
|
return Html::fileField($element['name'], $element['value'], $options); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* Render image field row |
224
|
|
|
* |
225
|
|
|
* @access public |
226
|
|
|
* |
227
|
|
|
* @param IFormModel $model model |
228
|
|
|
* @param string $property model property |
229
|
|
|
* @param array $options attribute array |
230
|
|
|
* |
231
|
|
|
* @return string |
232
|
|
|
*/ |
233
|
|
View Code Duplication |
public function imageFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
234
|
|
|
{ |
235
|
|
|
$element = $this->getField($model, $property); |
236
|
|
|
$options['id'] = $element['id']; |
237
|
|
|
|
238
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
239
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
240
|
|
|
$this->imageField($model, $property, $options) . |
241
|
|
|
Html::closeTag('div'); |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* Render image field tag |
246
|
|
|
* |
247
|
|
|
* @access public |
248
|
|
|
* |
249
|
|
|
* @param IFormModel $model model |
250
|
|
|
* @param string $property model property |
251
|
|
|
* @param array $options attributes array |
252
|
|
|
* |
253
|
|
|
* @return string |
254
|
|
|
*/ |
255
|
|
|
public function imageField(IFormModel $model, $property, array $options = []) |
256
|
|
|
{ |
257
|
|
|
$element = $this->getField($model, $property); |
258
|
|
|
$options['id'] = $element['id']; |
259
|
|
|
$image = !empty($options['image']) ? $options['image'] : []; |
260
|
|
|
|
261
|
|
|
return Html::imageField($element['name'], $element['value'], $image, $options); |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* Render password field row |
266
|
|
|
* |
267
|
|
|
* @access public |
268
|
|
|
* |
269
|
|
|
* @param IFormModel $model model |
270
|
|
|
* @param string $property model property |
271
|
|
|
* @param array $options attribute array |
272
|
|
|
* |
273
|
|
|
* @return string |
274
|
|
|
*/ |
275
|
|
View Code Duplication |
public function passwordFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
276
|
|
|
{ |
277
|
|
|
$element = $this->getField($model, $property); |
278
|
|
|
$options['id'] = $element['id']; |
279
|
|
|
|
280
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
281
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
282
|
|
|
$this->passwordField($model, $property, $options) . |
283
|
|
|
Html::closeTag('div'); |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* Render password field tag |
288
|
|
|
* |
289
|
|
|
* @access public |
290
|
|
|
* |
291
|
|
|
* @param IFormModel $model model |
292
|
|
|
* @param string $property model property |
293
|
|
|
* @param array $options attributes array |
294
|
|
|
* |
295
|
|
|
* @return string |
296
|
|
|
*/ |
297
|
|
View Code Duplication |
public function passwordField(IFormModel $model, $property, array $options = []) |
|
|
|
|
298
|
|
|
{ |
299
|
|
|
$element = $this->getField($model, $property); |
300
|
|
|
$options['id'] = $element['id']; |
301
|
|
|
|
302
|
|
|
return Html::passwordField($element['name'], $element['value'], $options); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Render textArea field row |
307
|
|
|
* |
308
|
|
|
* @access public |
309
|
|
|
* |
310
|
|
|
* @param IFormModel $model model |
311
|
|
|
* @param string $property model property |
312
|
|
|
* @param array $options attribute array |
313
|
|
|
* |
314
|
|
|
* @return string |
315
|
|
|
*/ |
316
|
|
View Code Duplication |
public function textAreaFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
317
|
|
|
{ |
318
|
|
|
$element = $this->getField($model, $property); |
319
|
|
|
$options['id'] = $element['id']; |
320
|
|
|
|
321
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
322
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
323
|
|
|
$this->textAreaField($model, $property, $options) . |
324
|
|
|
Html::closeTag('div'); |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* Render textarea tag |
329
|
|
|
* |
330
|
|
|
* @access public |
331
|
|
|
* |
332
|
|
|
* @param IFormModel $model model |
333
|
|
|
* @param string $property model property |
334
|
|
|
* @param array $options attributes array |
335
|
|
|
* |
336
|
|
|
* @return string |
337
|
|
|
*/ |
338
|
|
View Code Duplication |
public function textAreaField(IFormModel $model, $property, array $options = []) |
|
|
|
|
339
|
|
|
{ |
340
|
|
|
$element = $this->getField($model, $property); |
341
|
|
|
$options['id'] = $element['id']; |
342
|
|
|
|
343
|
|
|
return Html::textArea($element['name'], $element['value'], $options); |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Render checkbox field row |
348
|
|
|
* |
349
|
|
|
* @access public |
350
|
|
|
* |
351
|
|
|
* @param IFormModel $model model |
352
|
|
|
* @param string $property model property |
353
|
|
|
* @param array $options attribute array |
354
|
|
|
* |
355
|
|
|
* @return string |
356
|
|
|
*/ |
357
|
|
View Code Duplication |
public function checkboxFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
358
|
|
|
{ |
359
|
|
|
$element = $this->getField($model, $property); |
360
|
|
|
$options['id'] = $element['id']; |
361
|
|
|
|
362
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
363
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
364
|
|
|
$this->checkBoxField($model, $property, $options) . |
365
|
|
|
Html::closeTag('div'); |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
/** |
369
|
|
|
* Render check box field tag |
370
|
|
|
* |
371
|
|
|
* @access public |
372
|
|
|
* |
373
|
|
|
* @param IFormModel $model model |
374
|
|
|
* @param string $property model property |
375
|
|
|
* @param array $options attributes array |
376
|
|
|
* |
377
|
|
|
* @return string |
378
|
|
|
*/ |
379
|
|
View Code Duplication |
public function checkBoxField(IFormModel $model, $property, array $options = []) |
|
|
|
|
380
|
|
|
{ |
381
|
|
|
$element = $this->getField($model, $property); |
382
|
|
|
$options['id'] = $element['id']; |
383
|
|
|
|
384
|
|
|
return Html::checkBoxField($element['name'], $element['value'], $options); |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
// Lists |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* Render listBox field row |
391
|
|
|
* |
392
|
|
|
* @access public |
393
|
|
|
* |
394
|
|
|
* @param IFormModel $model model |
395
|
|
|
* @param string $property model property |
396
|
|
|
* @param array $options attribute array |
397
|
|
|
* |
398
|
|
|
* @return string |
399
|
|
|
*/ |
400
|
|
View Code Duplication |
public function listBoxFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
401
|
|
|
{ |
402
|
|
|
$element = $this->getField($model, $property); |
403
|
|
|
$options['id'] = $element['id']; |
404
|
|
|
|
405
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
406
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
407
|
|
|
$this->listBoxField($model, $property, $options) . |
408
|
|
|
Html::closeTag('div'); |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
/** |
412
|
|
|
* Render list box tag |
413
|
|
|
* |
414
|
|
|
* @access public |
415
|
|
|
* |
416
|
|
|
* @param IFormModel $model model |
417
|
|
|
* @param string $property model property |
418
|
|
|
* @param array $options attributes array |
419
|
|
|
* |
420
|
|
|
* @return string |
421
|
|
|
*/ |
422
|
|
View Code Duplication |
public function listBoxField(IFormModel $model, $property, array $options = []) |
|
|
|
|
423
|
|
|
{ |
424
|
|
|
$element = $this->getField($model, $property); |
425
|
|
|
$options['id'] = $element['id']; |
426
|
|
|
$options['selected'] = $element['value']; |
427
|
|
|
|
428
|
|
|
if (empty($options['size'])) { |
429
|
|
|
$options['size'] = 3; |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
return Html::listBox($element['name'], $this->getBlock('elements', $options), $options); |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* Render text field row |
437
|
|
|
* |
438
|
|
|
* @access public |
439
|
|
|
* |
440
|
|
|
* @param IFormModel $model model |
441
|
|
|
* @param string $property model property |
442
|
|
|
* @param array $options attribute array |
443
|
|
|
* |
444
|
|
|
* @return string |
445
|
|
|
*/ |
446
|
|
View Code Duplication |
public function dropDownListFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
447
|
|
|
{ |
448
|
|
|
$element = $this->getField($model, $property); |
449
|
|
|
$options['id'] = $element['id']; |
450
|
|
|
|
451
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
452
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
453
|
|
|
$this->dropDownListField($model, $property, $options) . |
454
|
|
|
Html::closeTag('div'); |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
/** |
458
|
|
|
* Render drop down list tag |
459
|
|
|
* |
460
|
|
|
* @access public |
461
|
|
|
* |
462
|
|
|
* @param IFormModel $model model |
463
|
|
|
* @param string $property model property |
464
|
|
|
* @param array $options attribute array |
465
|
|
|
* |
466
|
|
|
* @return string |
467
|
|
|
*/ |
468
|
|
View Code Duplication |
public function dropDownListField(IFormModel $model, $property, array $options = []) |
|
|
|
|
469
|
|
|
{ |
470
|
|
|
$element = $this->getField($model, $property); |
471
|
|
|
$options['id'] = $element['id']; |
472
|
|
|
|
473
|
|
|
if (!empty($element['value'])) { |
474
|
|
|
$options['selected'] = $element['value']; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
return Html::dropDownList($element['name'], $this->getBlock('elements', $options), $options); |
478
|
|
|
} |
479
|
|
|
|
480
|
|
|
/** |
481
|
|
|
* Render text field row |
482
|
|
|
* |
483
|
|
|
* @access public |
484
|
|
|
* |
485
|
|
|
* @param IFormModel $model model |
486
|
|
|
* @param string $property model property |
487
|
|
|
* @param array $options options array |
488
|
|
|
* |
489
|
|
|
* @return string |
490
|
|
|
*/ |
491
|
|
View Code Duplication |
public function checkBoxListFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
492
|
|
|
{ |
493
|
|
|
$element = $this->getField($model, $property); |
494
|
|
|
$options['id'] = $element['id']; |
495
|
|
|
|
496
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
497
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
498
|
|
|
$this->checkBoxListField($model, $property, $options) . |
499
|
|
|
Html::closeTag('div'); |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
/** |
503
|
|
|
* Render check box list tag |
504
|
|
|
* |
505
|
|
|
* @access public |
506
|
|
|
* |
507
|
|
|
* @param IFormModel $model model |
508
|
|
|
* @param string $property property model |
509
|
|
|
* @param array $options options array |
510
|
|
|
* |
511
|
|
|
* @return string |
512
|
|
|
*/ |
513
|
|
|
public function checkBoxListField(IFormModel $model, $property, array $options = []) |
514
|
|
|
{ |
515
|
|
|
$element = $this->getField($model, $property); |
516
|
|
|
$checkboxes = !empty($options['checkboxes']) ? $options['checkboxes'] : []; |
517
|
|
|
$format = !empty($options['format']) ? $options['format'] : '<p>%check% %text%</p>'; |
518
|
|
|
|
519
|
|
|
return Html::checkBoxList($element['name'], $checkboxes, $format, $element['value']); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* Render text field row |
524
|
|
|
* |
525
|
|
|
* @access public |
526
|
|
|
* |
527
|
|
|
* @param IFormModel $model model |
528
|
|
|
* @param string $property model property |
529
|
|
|
* @param array $options options array |
530
|
|
|
* |
531
|
|
|
* @return string |
532
|
|
|
*/ |
533
|
|
View Code Duplication |
public function radioButtonListFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
534
|
|
|
{ |
535
|
|
|
$element = $this->getField($model, $property); |
536
|
|
|
$options['id'] = $element['id']; |
537
|
|
|
|
538
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
539
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
540
|
|
|
$this->radioButtonListField($model, $property, $options) . |
541
|
|
|
Html::closeTag('div'); |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
/** |
545
|
|
|
* Render radio button list tag |
546
|
|
|
* |
547
|
|
|
* @access public |
548
|
|
|
* |
549
|
|
|
* @param IFormModel $model model |
550
|
|
|
* @param string $property model property |
551
|
|
|
* @param array $options options array |
552
|
|
|
* |
553
|
|
|
* @return string |
554
|
|
|
*/ |
555
|
|
|
public function radioButtonListField(IFormModel $model, $property, array $options = []) |
556
|
|
|
{ |
557
|
|
|
$element = $this->getField($model, $property); |
558
|
|
|
$radios = !empty($options['radios']) ? $options['radios'] : []; |
559
|
|
|
$format = !empty($options['format']) ? $options['format'] : '<p>%radio% %text%</p>'; |
560
|
|
|
|
561
|
|
|
return Html::radioButtonList($element['name'], $radios, $format, $element['value']); |
562
|
|
|
} |
563
|
|
|
|
564
|
|
|
// HTML5 Fields |
565
|
|
|
|
566
|
|
|
/** |
567
|
|
|
* Render color field row |
568
|
|
|
* |
569
|
|
|
* @access public |
570
|
|
|
* |
571
|
|
|
* @param IFormModel $model model |
572
|
|
|
* @param string $property model property |
573
|
|
|
* @param array $options attribute array |
574
|
|
|
* |
575
|
|
|
* @return string |
576
|
|
|
*/ |
577
|
|
View Code Duplication |
public function colorFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
578
|
|
|
{ |
579
|
|
|
$element = $this->getField($model, $property); |
580
|
|
|
$options['id'] = $element['id']; |
581
|
|
|
|
582
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
583
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
584
|
|
|
$this->colorField($model, $property, $options) . |
585
|
|
|
Html::closeTag('div'); |
586
|
|
|
} |
587
|
|
|
|
588
|
|
|
/** |
589
|
|
|
* Render color field tag |
590
|
|
|
* |
591
|
|
|
* @access public |
592
|
|
|
* |
593
|
|
|
* @param IFormModel $model model |
594
|
|
|
* @param string $property model property |
595
|
|
|
* @param array $options attributes array |
596
|
|
|
* |
597
|
|
|
* @return string |
598
|
|
|
*/ |
599
|
|
View Code Duplication |
public function colorField(IFormModel $model, $property, array $options = []) |
|
|
|
|
600
|
|
|
{ |
601
|
|
|
$element = $this->getField($model, $property); |
602
|
|
|
$options['id'] = $element['id']; |
603
|
|
|
|
604
|
|
|
return Html::colorField($element['name'], $element['value'], $options); |
605
|
|
|
} |
606
|
|
|
|
607
|
|
|
/** |
608
|
|
|
* Render number field row |
609
|
|
|
* |
610
|
|
|
* @access public |
611
|
|
|
* |
612
|
|
|
* @param IFormModel $model model |
613
|
|
|
* @param string $property model property |
614
|
|
|
* @param array $options attribute array |
615
|
|
|
* |
616
|
|
|
* @return string |
617
|
|
|
*/ |
618
|
|
View Code Duplication |
public function dateFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
619
|
|
|
{ |
620
|
|
|
$element = $this->getField($model, $property); |
621
|
|
|
$options['id'] = $element['id']; |
622
|
|
|
|
623
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
624
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
625
|
|
|
$this->dateField($model, $property, $options) . |
626
|
|
|
Html::closeTag('div'); |
627
|
|
|
} |
628
|
|
|
|
629
|
|
|
/** |
630
|
|
|
* Render date field tag |
631
|
|
|
* |
632
|
|
|
* @access public |
633
|
|
|
* |
634
|
|
|
* @param IFormModel $model model |
635
|
|
|
* @param string $property model property |
636
|
|
|
* @param array $options attributes array |
637
|
|
|
* |
638
|
|
|
* @return string |
639
|
|
|
*/ |
640
|
|
View Code Duplication |
public function dateField(IFormModel $model, $property, array $options = []) |
|
|
|
|
641
|
|
|
{ |
642
|
|
|
$element = $this->getField($model, $property); |
643
|
|
|
$options['id'] = $element['id']; |
644
|
|
|
|
645
|
|
|
return Html::dateField($element['name'], $element['value'], $options); |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
/** |
649
|
|
|
* Render datetime field row |
650
|
|
|
* |
651
|
|
|
* @access public |
652
|
|
|
* |
653
|
|
|
* @param IFormModel $model model |
654
|
|
|
* @param string $property model property |
655
|
|
|
* @param array $options attribute array |
656
|
|
|
* |
657
|
|
|
* @return string |
658
|
|
|
*/ |
659
|
|
View Code Duplication |
public function dateTimeFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
660
|
|
|
{ |
661
|
|
|
$element = $this->getField($model, $property); |
662
|
|
|
$options['id'] = $element['id']; |
663
|
|
|
|
664
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
665
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
666
|
|
|
$this->dateTimeField($model, $property, $options) . |
667
|
|
|
Html::closeTag('div'); |
668
|
|
|
} |
669
|
|
|
|
670
|
|
|
/** |
671
|
|
|
* Render datetime field tag |
672
|
|
|
* |
673
|
|
|
* @access public |
674
|
|
|
* |
675
|
|
|
* @param IFormModel $model model |
676
|
|
|
* @param string $property model property |
677
|
|
|
* @param array $options attributes array |
678
|
|
|
* |
679
|
|
|
* @return string |
680
|
|
|
*/ |
681
|
|
View Code Duplication |
public function dateTimeField(IFormModel $model, $property, array $options = []) |
|
|
|
|
682
|
|
|
{ |
683
|
|
|
$element = $this->getField($model, $property); |
684
|
|
|
$options['id'] = $element['id']; |
685
|
|
|
|
686
|
|
|
return Html::datetimeField($element['name'], $element['value'], $options); |
687
|
|
|
} |
688
|
|
|
|
689
|
|
|
/** |
690
|
|
|
* Render datetime-local field row |
691
|
|
|
* |
692
|
|
|
* @access public |
693
|
|
|
* |
694
|
|
|
* @param IFormModel $model model |
695
|
|
|
* @param string $property model property |
696
|
|
|
* @param array $options attribute array |
697
|
|
|
* |
698
|
|
|
* @return string |
699
|
|
|
*/ |
700
|
|
View Code Duplication |
public function dateTimeLocalFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
701
|
|
|
{ |
702
|
|
|
$element = $this->getField($model, $property); |
703
|
|
|
$options['id'] = $element['id']; |
704
|
|
|
|
705
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
706
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
707
|
|
|
$this->dateTimeLocalField($model, $property, $options) . |
708
|
|
|
Html::closeTag('div'); |
709
|
|
|
} |
710
|
|
|
|
711
|
|
|
/** |
712
|
|
|
* Render datetime-local field tag |
713
|
|
|
* |
714
|
|
|
* @access public |
715
|
|
|
* |
716
|
|
|
* @param IFormModel $model model |
717
|
|
|
* @param string $property model property |
718
|
|
|
* @param array $options attributes array |
719
|
|
|
* |
720
|
|
|
* @return string |
721
|
|
|
*/ |
722
|
|
View Code Duplication |
public function dateTimeLocalField(IFormModel $model, $property, array $options = []) |
|
|
|
|
723
|
|
|
{ |
724
|
|
|
$element = $this->getField($model, $property); |
725
|
|
|
$options['id'] = $element['id']; |
726
|
|
|
|
727
|
|
|
return Html::datetimeLocalField($element['name'], $element['value'], $options); |
728
|
|
|
} |
729
|
|
|
|
730
|
|
|
/** |
731
|
|
|
* Render email field row |
732
|
|
|
* |
733
|
|
|
* @access public |
734
|
|
|
* |
735
|
|
|
* @param IFormModel $model model |
736
|
|
|
* @param string $property model property |
737
|
|
|
* @param array $options attribute array |
738
|
|
|
* |
739
|
|
|
* @return string |
740
|
|
|
*/ |
741
|
|
View Code Duplication |
public function emailFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
742
|
|
|
{ |
743
|
|
|
$element = $this->getField($model, $property); |
744
|
|
|
$options['id'] = $element['id']; |
745
|
|
|
|
746
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
747
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
748
|
|
|
$this->emailField($model, $property, $options) . |
749
|
|
|
Html::closeTag('div'); |
750
|
|
|
} |
751
|
|
|
|
752
|
|
|
/** |
753
|
|
|
* Render email field tag |
754
|
|
|
* |
755
|
|
|
* @access public |
756
|
|
|
* |
757
|
|
|
* @param IFormModel $model model |
758
|
|
|
* @param string $property model property |
759
|
|
|
* @param array $options attributes array |
760
|
|
|
* |
761
|
|
|
* @return string |
762
|
|
|
*/ |
763
|
|
View Code Duplication |
public function emailField(IFormModel $model, $property, array $options = []) |
|
|
|
|
764
|
|
|
{ |
765
|
|
|
$element = $this->getField($model, $property); |
766
|
|
|
$options['id'] = $element['id']; |
767
|
|
|
|
768
|
|
|
return Html::emailField($element['name'], $element['value'], $options); |
769
|
|
|
} |
770
|
|
|
|
771
|
|
|
/** |
772
|
|
|
* Render number field row |
773
|
|
|
* |
774
|
|
|
* @access public |
775
|
|
|
* |
776
|
|
|
* @param IFormModel $model model |
777
|
|
|
* @param string $property model property |
778
|
|
|
* @param array $options attribute array |
779
|
|
|
* |
780
|
|
|
* @return string |
781
|
|
|
*/ |
782
|
|
View Code Duplication |
public function numberFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
783
|
|
|
{ |
784
|
|
|
$element = $this->getField($model, $property); |
785
|
|
|
$options['id'] = $element['id']; |
786
|
|
|
|
787
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
788
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
789
|
|
|
$this->numberField($model, $property, $options) . |
790
|
|
|
Html::closeTag('div'); |
791
|
|
|
} |
792
|
|
|
|
793
|
|
|
/** |
794
|
|
|
* Render number field tag |
795
|
|
|
* |
796
|
|
|
* @access public |
797
|
|
|
* |
798
|
|
|
* @param IFormModel $model model |
799
|
|
|
* @param string $property model property |
800
|
|
|
* @param array $options attributes array |
801
|
|
|
* |
802
|
|
|
* @return string |
803
|
|
|
*/ |
804
|
|
View Code Duplication |
public function numberField(IFormModel $model, $property, array $options = []) |
|
|
|
|
805
|
|
|
{ |
806
|
|
|
$element = $this->getField($model, $property); |
807
|
|
|
$options['id'] = $element['id']; |
808
|
|
|
|
809
|
|
|
return Html::numberField($element['name'], $element['value'], $options); |
810
|
|
|
} |
811
|
|
|
|
812
|
|
|
/** |
813
|
|
|
* Render range field row |
814
|
|
|
* |
815
|
|
|
* @access public |
816
|
|
|
* |
817
|
|
|
* @param IFormModel $model model |
818
|
|
|
* @param string $property model property |
819
|
|
|
* @param array $options attribute array |
820
|
|
|
* |
821
|
|
|
* @return string |
822
|
|
|
*/ |
823
|
|
View Code Duplication |
public function rangeFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
824
|
|
|
{ |
825
|
|
|
$element = $this->getField($model, $property); |
826
|
|
|
$options['id'] = $element['id']; |
827
|
|
|
|
828
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
829
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
830
|
|
|
$this->rangeField($model, $property, $options) . |
831
|
|
|
Html::closeTag('div'); |
832
|
|
|
} |
833
|
|
|
|
834
|
|
|
/** |
835
|
|
|
* Render range field tag |
836
|
|
|
* |
837
|
|
|
* @access public |
838
|
|
|
* |
839
|
|
|
* @param IFormModel $model model |
840
|
|
|
* @param string $property model property |
841
|
|
|
* @param array $options attributes array |
842
|
|
|
* |
843
|
|
|
* @return string |
844
|
|
|
*/ |
845
|
|
View Code Duplication |
public function rangeField(IFormModel $model, $property, array $options = []) |
|
|
|
|
846
|
|
|
{ |
847
|
|
|
$element = $this->getField($model, $property); |
848
|
|
|
$options['id'] = $element['id']; |
849
|
|
|
|
850
|
|
|
return Html::rangeField($element['name'], $element['value'], $options); |
851
|
|
|
} |
852
|
|
|
|
853
|
|
|
/** |
854
|
|
|
* Render search field row |
855
|
|
|
* |
856
|
|
|
* @access public |
857
|
|
|
* |
858
|
|
|
* @param IFormModel $model model |
859
|
|
|
* @param string $property model property |
860
|
|
|
* @param array $options attribute array |
861
|
|
|
* |
862
|
|
|
* @return string |
863
|
|
|
*/ |
864
|
|
View Code Duplication |
public function searchFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
865
|
|
|
{ |
866
|
|
|
$element = $this->getField($model, $property); |
867
|
|
|
$options['id'] = $element['id']; |
868
|
|
|
|
869
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
870
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
871
|
|
|
$this->searchField($model, $property, $options) . |
872
|
|
|
Html::closeTag('div'); |
873
|
|
|
} |
874
|
|
|
|
875
|
|
|
/** |
876
|
|
|
* Render search field tag |
877
|
|
|
* |
878
|
|
|
* @access public |
879
|
|
|
* |
880
|
|
|
* @param IFormModel $model model |
881
|
|
|
* @param string $property model property |
882
|
|
|
* @param array $options attributes array |
883
|
|
|
* |
884
|
|
|
* @return string |
885
|
|
|
*/ |
886
|
|
View Code Duplication |
public function searchField(IFormModel $model, $property, array $options = []) |
|
|
|
|
887
|
|
|
{ |
888
|
|
|
$element = $this->getField($model, $property); |
889
|
|
|
$options['id'] = $element['id']; |
890
|
|
|
|
891
|
|
|
return Html::searchField($element['name'], $element['value'], $options); |
892
|
|
|
} |
893
|
|
|
|
894
|
|
|
/** |
895
|
|
|
* Render telephone field row |
896
|
|
|
* |
897
|
|
|
* @access public |
898
|
|
|
* |
899
|
|
|
* @param IFormModel $model model |
900
|
|
|
* @param string $property model property |
901
|
|
|
* @param array $options attribute array |
902
|
|
|
* |
903
|
|
|
* @return string |
904
|
|
|
*/ |
905
|
|
View Code Duplication |
public function telFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
906
|
|
|
{ |
907
|
|
|
$element = $this->getField($model, $property); |
908
|
|
|
$options['id'] = $element['id']; |
909
|
|
|
|
910
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
911
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
912
|
|
|
$this->telField($model, $property, $options) . |
913
|
|
|
Html::closeTag('div'); |
914
|
|
|
} |
915
|
|
|
|
916
|
|
|
/** |
917
|
|
|
* Render telephone tag |
918
|
|
|
* |
919
|
|
|
* @access public |
920
|
|
|
* |
921
|
|
|
* @param IFormModel $model model |
922
|
|
|
* @param string $property model property |
923
|
|
|
* @param array $options attributes array |
924
|
|
|
* |
925
|
|
|
* @return string |
926
|
|
|
*/ |
927
|
|
View Code Duplication |
public function telField(IFormModel $model, $property, array $options = []) |
|
|
|
|
928
|
|
|
{ |
929
|
|
|
$element = $this->getField($model, $property); |
930
|
|
|
$options['id'] = $element['id']; |
931
|
|
|
|
932
|
|
|
return Html::telField($element['name'], $element['value'], $options); |
933
|
|
|
} |
934
|
|
|
|
935
|
|
|
/** |
936
|
|
|
* Render time field row |
937
|
|
|
* |
938
|
|
|
* @access public |
939
|
|
|
* |
940
|
|
|
* @param IFormModel $model model |
941
|
|
|
* @param string $property model property |
942
|
|
|
* @param array $options attribute array |
943
|
|
|
* |
944
|
|
|
* @return string |
945
|
|
|
*/ |
946
|
|
View Code Duplication |
public function timeFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
947
|
|
|
{ |
948
|
|
|
$element = $this->getField($model, $property); |
949
|
|
|
$options['id'] = $element['id']; |
950
|
|
|
|
951
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
952
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
953
|
|
|
$this->timeField($model, $property, $options) . |
954
|
|
|
Html::closeTag('div'); |
955
|
|
|
} |
956
|
|
|
|
957
|
|
|
/** |
958
|
|
|
* Render time field tag |
959
|
|
|
* |
960
|
|
|
* @access public |
961
|
|
|
* |
962
|
|
|
* @param IFormModel $model model |
963
|
|
|
* @param string $property model property |
964
|
|
|
* @param array $options attributes array |
965
|
|
|
* |
966
|
|
|
* @return string |
967
|
|
|
*/ |
968
|
|
View Code Duplication |
public function timeField(IFormModel $model, $property, array $options = []) |
|
|
|
|
969
|
|
|
{ |
970
|
|
|
$element = $this->getField($model, $property); |
971
|
|
|
$options['id'] = $element['id']; |
972
|
|
|
|
973
|
|
|
return Html::timeField($element['name'], $element['value'], $options); |
974
|
|
|
} |
975
|
|
|
|
976
|
|
|
/** |
977
|
|
|
* Render url field row |
978
|
|
|
* |
979
|
|
|
* @access public |
980
|
|
|
* |
981
|
|
|
* @param IFormModel $model model |
982
|
|
|
* @param string $property model property |
983
|
|
|
* @param array $options attribute array |
984
|
|
|
* |
985
|
|
|
* @return string |
986
|
|
|
*/ |
987
|
|
View Code Duplication |
public function urlFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
988
|
|
|
{ |
989
|
|
|
$element = $this->getField($model, $property); |
990
|
|
|
$options['id'] = $element['id']; |
991
|
|
|
|
992
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
993
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
994
|
|
|
$this->urlField($model, $property, $options) . |
995
|
|
|
Html::closeTag('div'); |
996
|
|
|
} |
997
|
|
|
|
998
|
|
|
/** |
999
|
|
|
* Render url field tag |
1000
|
|
|
* |
1001
|
|
|
* @access public |
1002
|
|
|
* |
1003
|
|
|
* @param IFormModel $model model |
1004
|
|
|
* @param string $property model property |
1005
|
|
|
* @param array $options attributes array |
1006
|
|
|
* |
1007
|
|
|
* @return string |
1008
|
|
|
*/ |
1009
|
|
View Code Duplication |
public function urlField(IFormModel $model, $property, array $options = []) |
|
|
|
|
1010
|
|
|
{ |
1011
|
|
|
$element = $this->getField($model, $property); |
1012
|
|
|
$options['id'] = $element['id']; |
1013
|
|
|
|
1014
|
|
|
return Html::urlField($element['name'], $element['value'], $options); |
1015
|
|
|
} |
1016
|
|
|
|
1017
|
|
|
/** |
1018
|
|
|
* Render month field row |
1019
|
|
|
* |
1020
|
|
|
* @access public |
1021
|
|
|
* |
1022
|
|
|
* @param IFormModel $model model |
1023
|
|
|
* @param string $property model property |
1024
|
|
|
* @param array $options attribute array |
1025
|
|
|
* |
1026
|
|
|
* @return string |
1027
|
|
|
*/ |
1028
|
|
View Code Duplication |
public function monthFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
1029
|
|
|
{ |
1030
|
|
|
$element = $this->getField($model, $property); |
1031
|
|
|
$options['id'] = $element['id']; |
1032
|
|
|
|
1033
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
1034
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
1035
|
|
|
$this->monthField($model, $property, $options) . |
1036
|
|
|
Html::closeTag('div'); |
1037
|
|
|
} |
1038
|
|
|
|
1039
|
|
|
/** |
1040
|
|
|
* Render moth field tag |
1041
|
|
|
* |
1042
|
|
|
* @access public |
1043
|
|
|
* |
1044
|
|
|
* @param IFormModel $model model |
1045
|
|
|
* @param string $property model property |
1046
|
|
|
* @param array $options attributes array |
1047
|
|
|
* |
1048
|
|
|
* @return string |
1049
|
|
|
*/ |
1050
|
|
View Code Duplication |
public function monthField(IFormModel $model, $property, array $options = []) |
|
|
|
|
1051
|
|
|
{ |
1052
|
|
|
$element = $this->getField($model, $property); |
1053
|
|
|
$options['id'] = $element['id']; |
1054
|
|
|
|
1055
|
|
|
return Html::monthField($element['name'], $element['value'], $options); |
1056
|
|
|
} |
1057
|
|
|
|
1058
|
|
|
/** |
1059
|
|
|
* Render week field row |
1060
|
|
|
* |
1061
|
|
|
* @access public |
1062
|
|
|
* |
1063
|
|
|
* @param IFormModel $model model |
1064
|
|
|
* @param string $property model property |
1065
|
|
|
* @param array $options attribute array |
1066
|
|
|
* |
1067
|
|
|
* @return string |
1068
|
|
|
*/ |
1069
|
|
View Code Duplication |
public function weekFieldRow(IFormModel $model, $property, array $options = []) |
|
|
|
|
1070
|
|
|
{ |
1071
|
|
|
$element = $this->getField($model, $property); |
1072
|
|
|
$options['id'] = $element['id']; |
1073
|
|
|
|
1074
|
|
|
return Html::openTag('div', $this->getBlock('block', $options)) . |
1075
|
|
|
Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)) . |
1076
|
|
|
$this->weekField($model, $property, $options) . |
1077
|
|
|
Html::closeTag('div'); |
1078
|
|
|
} |
1079
|
|
|
|
1080
|
|
|
/** |
1081
|
|
|
* Render week field tag |
1082
|
|
|
* |
1083
|
|
|
* @access public |
1084
|
|
|
* |
1085
|
|
|
* @param IFormModel $model model |
1086
|
|
|
* @param string $property model property |
1087
|
|
|
* @param array $options attributes array |
1088
|
|
|
* |
1089
|
|
|
* @return string |
1090
|
|
|
*/ |
1091
|
|
View Code Duplication |
public function weekField(IFormModel $model, $property, array $options = []) |
|
|
|
|
1092
|
|
|
{ |
1093
|
|
|
$element = $this->getField($model, $property); |
1094
|
|
|
$options['id'] = $element['id']; |
1095
|
|
|
|
1096
|
|
|
return Html::weekField($element['name'], $element['value'], $options); |
1097
|
|
|
} |
1098
|
|
|
} |
1099
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.