-
Notifications
You must be signed in to change notification settings - Fork 1
/
partial_fields.pdt
80 lines (74 loc) · 3.05 KB
/
partial_fields.pdt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
if (!empty($fields) || !empty($html)) {
?>
<div class="generated_fields_div">
<?php
foreach ((isset($fields) ? $fields : []) as $field) {
// Set any hidden fields
foreach ($field->fields as $input) {
if ($input->type == 'fieldHidden') {
call_user_func_array([$this->Form, $input->type], $input->params);
continue 2;
}
}
if ($field->type != 'fieldHidden') {
?>
<div class="form-group">
<?php
}
// Draw the primary label/field
call_user_func_array([$this->Form, $field->type], $field->params);
// Draw each form field associated with this label
foreach ($field->fields as $input) {
// Draw each tooltip
if ($input->type == 'tooltip') {
?>
<a href="#" data-toggle="tooltip" data-html="true" title="<?php (print (isset($input->params['message']) ? $this->Html->safe($input->params['message']) : null));?>"><i class="fas fa-question-circle text-info"></i></a>
<?php
continue;
} else {
// Draw the form field's secondary label if checkbox or radio item
if (($input->type == 'fieldCheckbox' || $input->type == 'fieldRadio') && isset($input->label)) {
$class = ($input->type == 'fieldRadio' ? 'radio' : 'checkbox');
?>
<div class="<?php (print (isset($class) ? $this->Html->safe($class) : null));?>">
<label<?php echo $this->Html->buildAttributes($input->label->params);?>>
<?php
call_user_func_array([$this->Form, $input->type], $input->params);
(print (isset($input->label->params['name']) ? $this->Html->safe($input->label->params['name']) : null));
?>
</label>
</div>
<?php
} else {
// Set form field class
if (isset($input->params['attributes']['class'])) {
if (is_array($input->params['attributes']['class'])) {
$input->params['attributes']['class'][] = 'form-control';
} else {
$input->params['attributes']['class'] .= ' form-control';
}
} else {
$input->params['attributes']['class'] = 'form-control';
}
// Draw the form field
call_user_func_array([$this->Form, $input->type], $input->params);
// Show form field's secondary label
if (isset($input->label)) {
call_user_func_array([$this->Form, 'label'], $input->label->params);
}
}
}
}
if ($field->type != 'fieldHidden') {
?>
</div>
<?php
}
}
?>
<?php echo (isset($html) ? $html : null);?>
<div class="clearfix"></div>
</div>
<?php
}