PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/Frontend/Form/View/Theme/Fields/HtmlSelectField.php +109 -58 2.10.0 → 3.3.1 View file →
@@ -19,9 +19,9 @@
19 19 if (isset($opt->val) && $opt->val === $val) {
20 20 $selected = 'selected';
21 21 } elseif (isset($opt->lbl) && $opt->lbl === $val) {
22 22 $selected = 'selected';
23 - } elseif (property_exists($opt, 'check')) {
23 + } elseif (is_object($opt) && property_exists($opt, 'check')) {
24 24 $selected = 'selected';
25 25 }
26 26 return $selected;
27 27 }
@@ -31,8 +31,10 @@
31 31 $fieldHelpers = new ClassicFieldHelpers($field, $rowID, $form_atomic_Cls_map);
32 32 $disabled = $fieldHelpers->disabled();
33 33 $readonly = $fieldHelpers->readonly();
34 34 $name = $fieldHelpers->name();
35 + $ariaDescribedBy = $fieldHelpers->ariaDescribedBy();
36 + $ariaRequired = $fieldHelpers->ariaRequired();
35 37 $value = '';
36 38 if ($v) {
37 39 $value = $v;
38 40 } elseif (isset($field->val)) {
@@ -44,83 +46,132 @@
44 46 $optionsHTML = '';
45 47 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
46 48 $contentCount = count($bfFrontendFormIds);
47 49 if ($fieldHelpers->property_exists_nested($field, 'phHide', true)) {
48 - $phHide = <<<PHHIDE
49 - <option
50 - {$fieldHelpers->getCustomAttributes('slct-optn')}
51 - class="{$fieldHelpers->getAtomicCls('slct-optn')} {$fieldHelpers->getCustomClasses('slct-optn')}"
50 + $phHide = sprintf(
51 + '<option
52 + %1$s
53 + class="%2$s %3$s"
52 54 value
53 55 >
54 - {$fieldHelpers->kses_post($field->ph)}
55 - </option>
56 -PHHIDE;
56 + %4$s
57 + </option>',
58 + $fieldHelpers->getCustomAttributes('slct-optn'),
59 + $fieldHelpers->getAtomicCls('slct-optn'),
60 + $fieldHelpers->getCustomClasses('slct-optn'),
61 + $fieldHelpers->kses_post($field->ph)
62 + );
57 63 }
58 64
59 - if (property_exists($field, 'opt')) {
65 + if (property_exists($field, 'opt') && is_iterable($field->opt)) {
60 66 foreach ($field->opt as $opt) {
67 + if (!is_object($opt)) {
68 + continue;
69 + }
61 70 $disabled = property_exists($opt, 'disabled') ? 'disabled' : '';
62 71 if (property_exists($opt, 'type')) {
63 - $optionsHTML .= <<<OPTGRP
64 - <optgroup
65 - {$fieldHelpers->getCustomAttributes('slct-opt-grp')}
66 - class="{$fieldHelpers->getAtomicCls('slct-opt-grp')} {$fieldHelpers->getCustomClasses('slct-opt-grp')}"
67 - label="{$fieldHelpers->esc_attr($opt->title)}"
68 - {$disabled}
69 - >
70 -OPTGRP;
71 - foreach ($opt->childs as $child) {
72 - $val = !empty($child->val) ? $child->val : $child->lbl;
72 + $optionsHTML .= sprintf(
73 + '<optgroup
74 + %1$s
75 + class="%2$s %3$s"
76 + label="%4$s"
77 + %5$s
78 + >',
79 + $fieldHelpers->getCustomAttributes('slct-opt-grp'),
80 + $fieldHelpers->getAtomicCls('slct-opt-grp'),
81 + $fieldHelpers->getCustomClasses('slct-opt-grp'),
82 + $fieldHelpers->esc_attr($opt->title),
83 + $disabled
84 + );
85 + $optChilds = isset($opt->childs) && is_iterable($opt->childs) ? $opt->childs : [];
86 + foreach ($optChilds as $child) {
87 + if (!is_object($child)) {
88 + continue;
89 + }
90 + $val = isset($child->val) ? $child->val : ($child->lbl ?? '');
73 91 $selected = self::checkSelected($child, $value);
74 92 $disabled = property_exists($child, 'disabled') ? 'disabled' : '';
75 - $optionsHTML .= <<<OPT
76 - <option
77 - {$fieldHelpers->getCustomAttributes('slct-optn')}
78 - class="{$fieldHelpers->getAtomicCls('slct-optn')} {$fieldHelpers->getCustomClasses('slct-optn')}"
79 - value="{$fieldHelpers->esc_attr($val)}"
80 - {$selected}
81 - {$disabled}
93 + $optionsHTML .= sprintf(
94 + '<option
95 + %1$s
96 + class="%2$s %3$s"
97 + value="%4$s"
98 + %5$s
99 + %6$s
82 100 >
83 - {$fieldHelpers->kses_post($child->lbl)}
84 - </option>
85 -OPT;
101 + %7$s
102 + </option>',
103 + $fieldHelpers->getCustomAttributes('slct-optn'),
104 + $fieldHelpers->getAtomicCls('slct-optn'),
105 + $fieldHelpers->getCustomClasses('slct-optn'),
106 + $fieldHelpers->esc_attr($val),
107 + $selected,
108 + $disabled,
109 + $fieldHelpers->kses_post($child->lbl)
110 + );
86 111 }
87 112 $optionsHTML .= '</optgroup>';
88 113 } else {
89 114 $selected = self::checkSelected($opt, $value);
90 - $val = !empty($opt->val) ? $opt->val : $opt->lbl;
91 - $optionsHTML .= <<<OPT
92 - <option
93 - {$fieldHelpers->getCustomAttributes('slct-optn')}
94 - class="{$fieldHelpers->getAtomicCls('slct-optn')} {$fieldHelpers->getCustomClasses('slct-optn')}"
95 - value="{$fieldHelpers->esc_attr($val)}"
96 - {$selected}
97 - {$disabled}
115 + $val = isset($opt->val) ? $opt->val : ($opt->lbl ?? '');
116 + $optionsHTML .= sprintf(
117 + '<option
118 + %1$s
119 + class="%2$s %3$s"
120 + value="%4$s"
121 + %5$s
122 + %6$s
98 123 >
99 - {$fieldHelpers->kses_post($opt->lbl)}
100 - </option>
101 -OPT;
124 + %7$s
125 + </option>',
126 + $fieldHelpers->getCustomAttributes('slct-optn'),
127 + $fieldHelpers->getAtomicCls('slct-optn'),
128 + $fieldHelpers->getCustomClasses('slct-optn'),
129 + $fieldHelpers->esc_attr($val),
130 + $selected,
131 + $disabled,
132 + $fieldHelpers->kses_post($opt->lbl)
133 + );
102 134 }
103 135 }
104 136 }
105 137
106 - return <<<HTMLSELECTFIELD
107 - <div
108 - {$fieldHelpers->getCustomAttributes('inp-fld-wrp')}
109 - class="{$fieldHelpers->getAtomicCls('inp-fld-wrp')} {$fieldHelpers->getCustomClasses('inp-fld-wrp')}"
110 - >
111 - <select
112 - {$fieldHelpers->getCustomAttributes('fld')}
113 - id="{$rowID}-{$contentCount}"
114 - class="{$fieldHelpers->getAtomicCls('fld')} {$fieldHelpers->getCustomClasses('fld')} {$readonlyCls}"
115 - {$readonly}
116 - {$disabled}
117 - {$name}
118 - value="{$fieldHelpers->esc_attr($value)}"
138 + return sprintf(
139 + '<div
140 + %1$s
141 + class="%2$s %3$s"
119 142 >
120 - {$phHide}
121 - {$optionsHTML}
122 - </select>
123 - </div>
124 -HTMLSELECTFIELD;
143 + <select
144 + %4$s
145 + id="%5$s-%6$s"
146 + class="%7$s %8$s %9$s"
147 + %10$s
148 + %11$s
149 + %12$s
150 + %13$s
151 + %14$s
152 + value="%15$s"
153 + >
154 + %16$s
155 + %17$s
156 + </select>
157 + </div>',
158 + $fieldHelpers->getCustomAttributes('inp-fld-wrp'),
159 + $fieldHelpers->getAtomicCls('inp-fld-wrp'),
160 + $fieldHelpers->getCustomClasses('inp-fld-wrp'),
161 + $fieldHelpers->getCustomAttributes('fld'),
162 + $rowID,
163 + $contentCount,
164 + $fieldHelpers->getAtomicCls('fld'),
165 + $fieldHelpers->getCustomClasses('fld'),
166 + $readonlyCls,
167 + $ariaRequired,
168 + $ariaDescribedBy,
169 + $readonly,
170 + $disabled,
171 + $name,
172 + $fieldHelpers->esc_attr($value),
173 + $phHide,
174 + $optionsHTML
175 + );
125 176 }
126 177 }