Completed
Push — master ( 3a258b...3917d8 )
by Andreas
13:50
created

form::form_widget_simple()   B

Complexity

Conditions 8
Paths 14

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 8

Importance

Changes 0
Metric Value
cc 8
eloc 12
nc 14
nop 2
dl 0
loc 19
ccs 13
cts 13
cp 1
crap 8
rs 8.4444
c 0
b 0
f 0
1
<?php
2
namespace midcom\datamanager\template;
3
4
use Symfony\Component\Form\FormView;
5
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
6
7
class form extends base
8
{
9 2
    private function get_view_renderer()
10
    {
11 2
        return new view($this->renderer);
12
    }
13
14 48
    public function form_start(FormView $view, array $data)
15
    {
16 48
        $attributes = $data['attr'];
17 48
        $attributes['name'] = $data['name'];
18 48
        $attributes['id'] = $data['name'];
19 48
        $attributes['method'] = strtolower($data['method']);
20 48
        $attributes['action'] = $data['action'];
21 48
        $attributes['class'] = 'datamanager2';
22
23 48
        if ($data['multipart']) {
24 10
            $attributes['enctype'] = 'multipart/form-data';
25
        }
26
27 48
        return '<form ' . $this->attributes($attributes) . '>';
28
    }
29
30 47
    public function form_errors(FormView $view, array $data)
31
    {
32 47
        $errors = [];
33 47
        foreach ($data['errors'] as $error) {
34
            $params = $error->getMessageParameters();
35
            $message = $error->getMessage();
36
            foreach ($params as $param) {
37
                if (strpos($message, $param)) {
38
                    $message = str_replace($param, $this->renderer->humanize($param), $message);
39
                }
40
            }
41
            $errors[] = '<div class="field_error">' . $this->renderer->humanize($message) . '</div>';
42
        }
43
44 47
        return implode('', $errors);
45
    }
46
47 47
    public function form_rows(FormView $view, array $data)
48
    {
49 47
        $string = '';
50 47
        foreach ($view as $child) {
51 47
            if (!empty($child->vars['hidden'])) {
52 6
                $child->setRendered();
53 6
                continue;
54
            }
55 47
            if ($child->vars['start_fieldset'] !== null) {
56 24
                if (!empty($child->vars['start_fieldset']['css_group'])) {
57 21
                    $class = $child->vars['start_fieldset']['css_group'];
58
                } else {
59 3
                    $class = $child->vars['name'];
60
                }
61 24
                $string .= '<fieldset class="fieldset ' . $class . '">';
62 24
                if (!empty($child->vars['start_fieldset']['title'])) {
63 24
                    $string .= '<legend>' . $this->renderer->humanize($child->vars['start_fieldset']['title']) . '</legend>';
64
                }
65
            }
66 47
            $string .= $this->renderer->row($child);
67 47
            if ($child->vars['end_fieldset'] !== null) {
68 27
                $end_fieldsets = max(1, (int) $child->vars['end_fieldset']);
69 47
                $string .= str_repeat('</fieldset>', $end_fieldsets);
70
            }
71
        }
72 47
        return $string;
73
    }
74
75 48
    public function form_end(FormView $view, array $data)
76
    {
77 48
        $string = '';
78 48
        if (   !isset($data['render_rest'])
79 48
            || $data['render_rest']) {
80 48
            $string .= $this->renderer->rest($view);
81
        }
82 48
        return $string . '</form>';
83
    }
84
85 46
    public function form_row(FormView $view, array $data)
86
    {
87 46
        $class = 'element element_' . $view->vars['block_prefixes'][count($view->vars['block_prefixes']) - 2];
88
89 46
        if ($view->vars['required']) {
90 27
            $class .= ' required';
91
        }
92
93 46
        if ($data['errors']->count() > 0) {
94
            $class .= ' error';
95
        }
96
97 46
        $string = '<div class="' . $class . '">';
98 46
        $string .= $this->renderer->label($view);
99 46
        $string .= '<div class="input">';
100 46
        $string .= $this->renderer->errors($view);
101 46
        $string .= $this->renderer->widget($view);
102 46
        return $string . '</div></div>';
103
    }
104
105 26
    public function autocomplete_row(FormView $view, array $data)
106
    {
107 26
        $class = 'element element_' . $view->vars['block_prefixes'][count($view->vars['block_prefixes']) - 2];
108
109 26
        if ($view->vars['required']) {
110 7
            $class .= ' required';
111
        }
112
113 26
        if ($data['errors']->count() > 0) {
114
            $class .= ' error';
115
        }
116
117 26
        $string = '<div class="' . $class . '">';
118 26
        $string .= $this->renderer->label($view);
119 26
        $string .= '<div class="input">';
120
121 26
        if ($data['errors']->count() > 0) {
122
            $string .= $this->renderer->errors($view) . '<br>';
123
        }
124 26
        $string .= $this->renderer->widget($view);
125 26
        return $string . '</div></div>';
126
    }
127
128
    public function button_row(FormView $view, array $data)
129
    {
130
        $string = '<div>';
131
        $string .= $this->renderer->widget($view);
132
        return $string . '</div>';
133
    }
134
135 16
    public function hidden_row(FormView $view, array $data)
136
    {
137 16
        return $this->renderer->widget($view);
138
    }
139
140 48
    public function toolbar_row(FormView $view, array $data)
141
    {
142 48
        $string = '<div class="form_toolbar">';
143 48
        foreach ($view as $child) {
144 48
            $string .= $this->renderer->widget($child);
145
        }
146 48
        return $string . '</div>';
147
    }
148
149 1
    public function repeated_row(FormView $view, array $data)
150
    {
151 1
        $view->children['second']->vars['label'] = $this->renderer->humanize($view->children['first']->vars['label']) . ' ' . $this->renderer->humanize($view->children['second']->vars['label']);
152 1
        $string = '';
153 1
        foreach ($view->children as $child) {
154 1
            $string .= $this->form_row($child, $data);
155
        }
156 1
        return $string;
157
    }
158
159 5
    public function attachment_row(FormView $view, array $data)
160
    {
161 5
        $string = '<fieldset ' . $this->renderer->block($view, 'widget_container_attributes') . '>';
162 5
        $string .= '<legend>';
163 5
        $string .= (!empty($data['value']['filename'])) ? $data['value']['filename'] : $this->renderer->humanize('add new file');
164 5
        $string .= '</legend>';
165
166 5
        $string .= '<div class="attachment-container">';
167 5
        $string .= '<div class="attachment-preview">';
168 5
        if (!empty($data['value']['filename'])) {
169
            $ext = pathinfo($data['value']['filename'], PATHINFO_EXTENSION);;
170
            $string .= '<a href="' . $data['value']['url'] . '" target="_blank" class="icon" title="' . $data['value']['filename'] . '">';
171
            $string .= '<i class="fa fa-file-o"></i><span class="extension">' . $ext . '</span></a>';
172
        } else {
173 5
            $string .= '<span class="icon no-file"><i class="fa fa-file-o"></i></span>';
174
        }
175
176 5
        $string .= '</div><div class="attachment-input">';
177 5
        foreach ($view->children as $child) {
178 5
            $string .= $this->renderer->row($child);
179
        }
180
181 5
        $string .= '</div></div>';
182 5
        $string .= $this->jsinit('dm_attachment_init("' . $data['form']['file']->vars['id'] . '")');
183 5
        return $string . '</fieldset>';
184
    }
185
186 4
    public function image_row(FormView $view, array $data)
187
    {
188 4
        if (!in_array('subform', $view->parent->vars['block_prefixes'])) {
189 3
            return $this->form_row($view, $data);
190
        }
191
192 1
        $string = '<fieldset ' . $this->renderer->block($view, 'widget_container_attributes') . '>';
193 1
        $string .= '<legend>';
194 1
        $string .= (!empty($data['value']['objects']['main']['filename'])) ? preg_replace('/^.+?\-/', '', $data['value']['objects']['main']['filename']) : $this->renderer->humanize('add new file');
195 1
        $string .= '</legend>';
196
197 1
        $string .= $this->renderer->widget($view);
198
199 1
        return $string . '</fieldset>';
200
    }
201
202 45
    public function form_widget_simple(FormView $view, array $data)
203
    {
204 45
        $type = isset($data['type']) ? $data['type'] : 'text';
205 45
        if ($view->vars['readonly'] && $type !== 'hidden') {
206 3
            return $data['value'] . $this->renderer->block($view, 'form_widget_simple', ['type' => "hidden"]);
207
        }
208
209 45
        if (!empty($data['attr']['class'])) {
210 14
            $view->vars['attr']['class'] = $data['attr']['class'];
211 45
        } elseif (in_array($type, ['text', 'password', 'email', 'url'])) {
212 45
            $view->vars['attr']['class'] = 'shorttext';
213
        }
214
215 45
        if (   !empty($data['value'])
216 45
            || is_numeric($data['value'])) {
217 40
            $view->vars['attr']['value'] = $data['value'];
218
        }
219 45
        $view->vars['attr']['type'] = $type;
220 45
        return '<input ' . $this->renderer->block($view, 'widget_attributes') . ' />';
221
    }
222
223 48
    public function button_widget(FormView $view, array $data)
224
    {
225 48
        $type = isset($data['type']) ? $data['type'] : 'button';
226 48
        if (!$data['label']) {
227
            $data['label'] = $data['name'];
228
        }
229
230 48
        return '<button type="' . $type . '" ' . $this->renderer->block($view, 'button_attributes') . '>' . $this->renderer->humanize($data['label']) . '</button>';
231
    }
232
233 32
    public function hidden_widget(FormView $view, array $data)
234
    {
235 32
        return $this->renderer->block($view, 'form_widget_simple', ['type' => isset($data['type']) ? $data['type'] : "hidden"]);
236
    }
237
238 9
    public function email_widget(FormView $view, array $data)
239
    {
240 9
        return $this->renderer->block($view, 'form_widget_simple', ['type' => isset($data['type']) ? $data['type'] : "email"]);
241
    }
242
243 1
    public function password_widget(FormView $view, array $data)
244
    {
245 1
        return $this->renderer->block($view, 'form_widget_simple', ['type' => isset($data['type']) ? $data['type'] : "password"]);
246
    }
247
248 5
    public function url_widget(FormView $view, array $data)
249
    {
250 5
        return $this->renderer->block($view, 'form_widget_simple', ['type' => isset($data['type']) ? $data['type'] : "url"]);
251
    }
252
253 26
    public function autocomplete_widget(FormView $view, array $data)
254
    {
255 26
        $element_id = $view->vars['id'];
256 26
        $jsinit = 'window.' . $element_id . '_handler_options = ' . $data['handler_options'] . ";\n";
257 26
        $jsinit .= "midcom_helper_datamanager2_autocomplete.create_dm2_widget('{$element_id}_search_input', {$data['min_chars']});\n";
258
259 26
        $string = '<fieldset ' . $this->renderer->block($view, 'widget_container_attributes') . '>';
260 26
        $string .=  $this->renderer->widget($view['selection']);
261 26
        $string .= ' ' . $this->renderer->widget($view['search_input']);
262 26
        $string .= '</fieldset>';
263 26
        return $string . $this->jsinit($jsinit);
264
    }
265
266 24
    protected function prepare_widget_attributes($type, FormView $view, array $data)
267
    {
268 24
        $view->vars['attr']['type'] = $type;
269 24
        if (isset($data['value'])) {
270 24
            $view->vars['attr']['value'] = $data['value'];
271
        }
272 24
        if ($data['checked']) {
273 16
            $view->vars['attr']['checked'] = 'checked';
274
        }
275 24
    }
276
277 15
    public function radio_widget(FormView $view, array $data)
278
    {
279 15
        $this->prepare_widget_attributes('radio', $view, $data);
280 15
        if ($view->vars['readonly']) {
281
            $view->vars['attr']['disabled'] = true;
282
        }
283
284 15
        return '<input ' . $this->renderer->block($view, 'widget_attributes') . ' />';
285
    }
286
287 15
    public function checkbox_widget(FormView $view, array $data)
288
    {
289 15
        if ($view->vars['readonly']) {
290
            $string = $this->get_view_renderer()->checkbox_widget($view, $data);
291
            if ($data['checked']) {
292
                $string .= $this->renderer->block($view, 'form_widget_simple', ['type' => "hidden"]);
293
            }
294
            return $string;
295
        }
296 15
        $this->prepare_widget_attributes('checkbox', $view, $data);
297
298 15
        return '<input ' . $this->renderer->block($view, 'widget_attributes') . ' />';
299
    }
300
301 27
    public function choice_widget_collapsed(FormView $view, array $data)
302
    {
303 27
        if ($view->vars['readonly'] && empty($view->vars['multiple'])) {
304
            $string = $this->get_view_renderer()->choice_widget_collapsed($view, $data);
305
            return $string . $this->renderer->block($view, 'form_widget_simple', ['type' => "hidden"]);
306
        }
307 27
        $string = '<select ';
308 27
        if (   $data['required']
309 27
            && null === $data['placeholder']
310 27
            && $data['placeholder_in_choices'] === false
311 27
            && $data['multiple'] === false) {
312
            $data['required'] = false;
313
        }
314
315 27
        if ($data['multiple']) {
316 4
            $view->vars['attr']['multiple'] = 'multiple';
317
        }
318
319 27
        $string .= $this->renderer->block($view, 'widget_attributes', ['required' => $data['required']]) . '>';
320 27
        if (null !== $data['placeholder']) {
321
            $string .= '<option value=""';
322
            if (   $data['required']
323
                && empty($data['value'])
324
                && "0" !== $data['value']) {
325
                $string .= ' selected="selected"';
326
            }
327
            $string .= '>' . $data['placeholder'] . '</option>';
328
        }
329 27
        if (count($data['preferred_choices']) > 0) {
330
            $string .= $this->renderer->block($view, 'choice_widget_options', ['choices' => $data['preferred_choices']]);
331
            if (count($data['choices']) > 0 && null !== $data['separator']) {
332
                $string .= '<option disabled="disabled">' . $data['separator'] . '</option>';
333
            }
334
        }
335 27
        $string .= $this->renderer->block($view, 'choice_widget_options', ['choices' => $data['choices']]);
336 27
        return $string . '</select>';
337
    }
338
339
    public function privilege_widget(FormView $view, array $data)
340
    {
341
        if (isset($view->vars['effective_value'])) {
342
            if ($view->vars['effective_value']) {
343
                $label = $this->renderer->humanize('widget privilege: allow');
344
            } else {
345
                $label = $this->renderer->humanize('widget privilege: deny');
346
            }
347
            $new_label = sprintf($this->renderer->humanize('widget privilege: inherit %s'), $label);
348
            $view->children[2]->vars['label'] = $new_label;
349
        }
350
        return $this->choice_widget_expanded($view, $data);
351
    }
352
353 1
    public function privilegeselection_widget(FormView $view, array $data)
354
    {
355 1
        $string = '<div class="holder">' . $this->choice_widget_collapsed($view, $data) . '</div>';
356 1
        return $string . $this->jsinit($view->vars['jsinit']);
357
    }
358
359 15
    public function choice_widget_expanded(FormView $view, array $data)
360
    {
361 15
        $string = '<fieldset ' . $this->renderer->block($view, 'widget_container_attributes') . '>';
362 15
        foreach ($view as $child) {
363 15
            $string .= $this->renderer->widget($child);
364 15
            $string .= '<label for="' . $child->vars['id'] . '">' . $this->renderer->humanize($child->vars['label']) . '</label>';
365
        }
366 15
        return $string . '</fieldset>';
367
    }
368
369 27
    public function choice_widget_options(FormView $view, array $data)
370
    {
371 27
        $string = '';
372 27
        foreach ($data['choices'] as $index => $choice) {
373 25
            if (is_array($choice) || $choice instanceof ChoiceGroupView) {
374
                $string .= '<optgroup label="' . $index . '">';
375
                $string .= $this->renderer->block($view, 'choice_widget_options', ['choices' => $choice]);
376
                $string .= '</optgroup>';
377
            } else {
378 25
                $choice->attr['value'] = $choice->value;
379 25
                if ($data['is_selected']($choice->value, $data['value'])) {
380 16
                    $choice->attr['selected'] = 'selected';
381
                }
382 25
                $string .= '<option ' . $this->attributes($choice->attr);
383 25
                $string .= '>' . $this->renderer->humanize($choice->label) . '</option>';
384
            }
385
        }
386 27
        return $string;
387
    }
388
389 2
    public function other_widget(FormView $view, array $data)
390
    {
391 2
        $string = '<fieldset ' . $this->renderer->block($view, 'widget_container_attributes') . '>';
392 2
        $string .= $this->renderer->widget($view->children['select']);
393 2
        $string .= $this->renderer->humanize($view->children['other']->vars['label']) . ': ' . $this->renderer->widget($view->children['other'], ['attr' => ['class' => 'other']]);
394 2
        return $string . '</fieldset>';
395
    }
396
397
    public function captcha_widget(FormView $view, array $data)
398
    {
399
        $alt = $this->renderer->humanize('captcha image alt text');
400
        $string = '<fieldset class="captcha">';
401
        $string .= "<img src='{$view->vars['captcha_url']}' alt='{$alt}' text='{$alt}' class='captcha'><br>";
402
        $string .= $this->renderer->humanize('captcha message');
403
        $data['attr']['class'] = 'captcha';
404
        $data['value'] = '';
405
        $string .= $this->form_widget_simple($view, $data);
406
        return $string . '</fieldset>';
407
    }
408
409 3
    public function codemirror_widget(FormView $view, array $data)
410
    {
411
        //we set required to false, because codemirror doesn't play well with html5 validation..
412 3
        $string = '<textarea ' . $this->renderer->block($view, 'widget_attributes', ['required' => false]) . '>';
413 3
        $string .= $data['value'] . '</textarea>';
414 3
        if (!empty($data['codemirror_snippet'])) {
415 3
            $snippet = str_replace('{$id}', $data['id'], $data['codemirror_snippet']);
416 3
            $snippet = str_replace('{$read_only}', 'false', $snippet);
417 3
            $string .= $this->jsinit($snippet);
418
        }
419 3
        return $string;
420
    }
421
422 12
    public function jsdate_widget(FormView $view, array $data)
423
    {
424 12
        $string = '<fieldset ' . $this->renderer->block($view, 'widget_container_attributes') . '>';
425
426 12
        if ($view->vars['readonly']) {
427 1
            $string .= $this->get_view_renderer()->jsdate_widget($view, $data);
428 1
            $string .= $this->renderer->widget($view['date'], ['type' => 'hidden']);
429 1
            if (isset($view['time'])) {
430 1
                $string .= $this->renderer->widget($view['time'], ['type' => 'hidden']);
431
            }
432
        } else {
433 12
            $string .= $this->renderer->widget($view['date'], ['type' => 'hidden']);
434 12
            $string .= $this->renderer->widget($view['input'], ['attr' => ['class' => 'jsdate']]);
435 12
            if (isset($view['time'])) {
436 1
                $string .= ' ' . $this->renderer->widget($view['time']);
437
            }
438 12
            $string .= $data['jsinit'];
439
        }
440 12
        return $string . '</fieldset>';
441
    }
442
443 4
    public function image_widget(FormView $view, array $data)
444
    {
445 4
        $string = '<div ' . $this->renderer->block($view, 'widget_container_attributes') . '>';
446 4
        $string .= '<table class="midcom_datamanager_table_photo"><tr><td>';
447 4
        $preview = null;
448 4
        $objects = isset($data['value']['objects']) ? $data['value']['objects'] : [];
449 4
        foreach ($objects as $identifier => $info) {
450
            $preview = $info;
451
            if ($identifier == 'thumbnail') {
452
                break;
453
            }
454
        }
455 4
        if (!empty($preview)) {
456
            if ($preview['id'] === 0) {
457
                $preview['url'] = \midcom_connection::get_url('self') . 'midcom-exec-midcom.datamanager/preview-tmpfile.php?identifier=' . substr($preview['identifier'], strlen('tmpfile-'));
458
            }
459
460
            $string .= '<img src="' . $preview['url'] . '" class="preview-image">';
461
        }
462 4
        $string .= '</td><td>';
463
464 4
        if (!empty($objects)) {
465
            $string .= '<label class="midcom_datamanager_photo_label">' . $this->renderer->humanize('delete photo') . ' ' . $this->renderer->widget($data['form']['delete']) . '</label>';
466
            $string .= '<ul>';
467
            foreach ($objects as $identifier => $info) {
468
                if (   $info['size_x']
469
                    && $info['size_y']) {
470
                    $size = "{$info['size_x']}&times;{$info['size_y']}";
471
                } else {
472
                    $size = 'unknown';
473
                }
474
                $string .= "<li title=\"{$info['guid']}\">{$size}: <a href='{$info['url']}' target='_new'>{$info['formattedsize']}</a></li>";
475
            }
476
            $string .= '</ul>';
477
        }
478 4
        $string .= $this->renderer->errors($data['form']['file']);
479 4
        $string .= $this->renderer->widget($data['form']['file']);
480
481 4
        if (array_key_exists('title', $view->children)) {
482 1
            $view->children['title']->vars['attr']['placeholder'] = $this->renderer->humanize('title');
483 1
            $string .= $this->renderer->widget($view->children['title']);
484
        }
485 4
        if (array_key_exists('description', $view->children)) {
486
            $view->children['description']->vars['attr']['placeholder'] = $this->renderer->humanize('description');
487
            $string .= $this->renderer->widget($view->children['description']);
488
        }
489 4
        $string .= '</td></tr></table></div>';
490 4
        $string .= $this->renderer->row($data['form']['identifier']);
491
492 4
        return $string . $this->jsinit('init_image_widget("' . $view->vars['id'] .'");');
493
    }
494
495 5
    public function subform_widget(FormView $view, array $data)
496
    {
497 5
        $view->vars['attr']['data-prototype'] = $this->escape($this->renderer->row($view->vars['prototype']));
498 5
        $view->vars['attr']['data-max-count'] = $view->vars['max_count'];
499 5
        $string = $this->renderer->widget($data['form'], $view->vars);
500 5
        return $string . $this->jsinit('init_subform("' . $view->vars['id'] . '", ' . $view->vars['sortable'] . ');');
501
    }
502
503 48
    public function submit_widget(FormView $view, array $data)
504
    {
505 48
        return $this->renderer->block($view, 'button_widget', ['type' => isset($data['type']) ? $data['type'] : 'submit']);
506
    }
507
508
    public function delete_widget(FormView $view, array $data)
509
    {
510
        return $this->renderer->block($view, 'button_widget', ['type' => isset($data['type']) ? $data['type'] : 'delete']);
511
    }
512
513 21
    public function textarea_widget(FormView $view, array $data)
514
    {
515 21
        if ($view->vars['readonly']) {
516 1
            $view->vars['output_mode'] = 'nl2br';
517 1
            $string = $this->get_view_renderer()->text_widget($view, $data);
518 1
            return $string . $this->renderer->block($view, 'form_widget_simple', ['type' => "hidden"]);
519
        }
520 20
        $view->vars['attr']['class'] = 'longtext';
521 20
        $view->vars['attr']['cols'] = 50;
522 20
        return '<textarea ' . $this->renderer->block($view, 'widget_attributes') . '>' . $data['value'] . '</textarea>';
523
    }
524
525 11
    public function markdown_widget(FormView $view, array $data)
526
    {
527 11
        $string = '<textarea ' . $this->renderer->block($view, 'widget_attributes', ['required' => false]) . '>' . $data['value'] . '</textarea>';
528 11
        return $string . $this->jsinit('var simplemde = new SimpleMDE({ element: document.getElementById("' . $view->vars['id'] . '"), status: false });');
529
    }
530
531 6
    public function tinymce_widget(FormView $view, array $data)
532
    {
533 6
        if ($view->vars['readonly']) {
534
            $string = $this->get_view_renderer()->text_widget($view, $data);
535
            return $string . $this->renderer->block($view, 'form_widget_simple', ['type' => "hidden"]);
536
        }
537
        //we set required to false, because tinymce doesn't play well with html5 validation..
538 6
        $string = '<textarea ' . $this->renderer->block($view, 'widget_attributes', ['required' => false]) . '>' . $data['value'] . '</textarea>';
539 6
        return $string . $this->jsinit($data['tinymce_snippet']);
540
    }
541
542 47
    public function form_label(FormView $view, array $data)
543
    {
544 47
        if ($data['label'] === false) {
545
            return '';
546
        }
547 47
        if (!$data['label']) {
548 5
            $data['label'] = $data['name'];
549
        }
550 47
        $data['label'] = $this->renderer->humanize($data['label']);
551
552 47
        $label_attr = $data['label_attr'];
553 47
        if ($data['required'] && !$view->vars['readonly']) {
554 29
            $label_attr['class'] = trim((isset($label_attr['class']) ? $label_attr['class'] : '') . ' required');
555 29
            $data['label'] .= ' <span class="field_required_start">*</span>';
556
        }
557 47
        if (!$data['compound']) {
558 47
            $label_attr['for'] = $data['id'];
559
        }
560 47
        return '<label ' . $this->attributes($label_attr) . '><span class="field_text">' . $data['label'] . '</span></label>';
561
    }
562
}
563