PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.0
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
bit-form / includes / Frontend / Form / View / Theme / Fields / RadioBoxField.php

RadioBoxField.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.0, at includes/Frontend/Form/View/Theme/Fields/RadioBoxField.php

147 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Frontend\Form\View\Theme\Fields;
4
5 class RadioBoxField {
6 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null) {
7 $inputWrapper = new InputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
8 $input = self::field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
9 return $inputWrapper->wrapper($input);
10 }
11
12 private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value) {
13 $fieldHelpers = new FieldHelpers($field, $rowID, $form_atomic_Cls_map);
14 $req = $fieldHelpers->required();
15 $name = $fieldHelpers->name();
16 $value = '';
17 $radioBoxOptions = '';
18 if (property_exists($field, 'opt') && count($field->opt) > 0) {
19 $defaultValue = isset($field->val) ? $field->val : '';
20 foreach ($field->opt as $key => $opt) {
21 $value = isset($opt->val) ? $opt->val : $opt->lbl;
22 $check = '';
23 $req = '';
24 $lbl = $fieldHelpers->renderHTMR($opt->lbl);
25 $disabled = '';
26 if ($fieldHelpers->property_exists_nested($opt, 'check', true)) {
27 $check = "checked='{$opt->check}'";
28 } else {
29 if ($value === $defaultValue) {
30 $check = "checked='checked'";
31 }
32 }
33 if ($fieldHelpers->property_exists_nested($opt, 'req', true)) {
34 $req = "required='{$opt->req}'";
35 }
36 if ($fieldHelpers->property_exists_nested($field, 'valid->disabled', true)
37 || $fieldHelpers->property_exists_nested($opt, 'disabled', true)) {
38 $disabled = "disabled='disabled'";
39 }
40
41 $radioBoxOptions .= <<<RADIOBOXOPTIONS
42 <div class="{$fieldHelpers->getAtomicCls('cw')} {$fieldHelpers->getCustomClasses('cw')}"
43 {$fieldHelpers->getCustomAttributes('cw')}
44 >
45 <input
46 id={$rowID}-chk-{$key}
47 type="radio"
48 class="{$fieldHelpers->getAtomicCls('ci')} {$fieldHelpers->getCustomClasses('ci')}"
49 value="{$value}"
50 {$check}
51 {$name}
52 {$req}
53 {$fieldHelpers->getCustomAttributes('ci')}
54 {$disabled}
55 />
56 <label
57 data-cl
58 for="{$rowID}-chk-{$key}"
59 class="{$fieldHelpers->getAtomicCls('cl')} {$fieldHelpers->getCustomClasses('cl')}"
60 {$fieldHelpers->getCustomAttributes('cl')}
61 >
62 <span
63 data-bx
64 class="{$fieldHelpers->getAtomicCls('bx')} {$fieldHelpers->getCustomClasses('bx')}"
65 {$fieldHelpers->getCustomAttributes('bx')}
66 >
67 <svg width="12" height="10" viewBox="0 0 12 10" class="{$fieldHelpers->getAtomicCls('svgwrp')} {$fieldHelpers->getCustomClasses('svgwrp')}">
68 <use data-ck-icn href=#{$rowID}-ck-svg class="{$fieldHelpers->getAtomicCls('ck-icn')} {$fieldHelpers->getCustomClasses('ck-icn')}" />
69 </svg>
70 </span>
71 <span
72 class="{$fieldHelpers->getAtomicCls('ct')} {$fieldHelpers->getCustomClasses('ct')}"
73 {$fieldHelpers->getCustomAttributes('ct')}
74 >
75 {$lbl}
76 </span>
77 </label>
78 </div>
79 RADIOBOXOPTIONS;
80 }
81 }
82
83 //Other Option
84 $optCount = property_exists($field, 'opt') ? count($field->opt) : 0;
85 $inputPh = isset($field->otherInpPh) ? $field->otherInpPh : 'Other...';
86 $inpReq = isset($field->valid->otherOptReq) ? ($field->valid->otherOptReq ? 'required' : '') : '';
87 if (property_exists($field, 'addOtherOpt') && $field->addOtherOpt) {
88 $radioBoxOptions .= <<<RADIOBOXOPTIONS
89 <div class="{$fieldHelpers->getAtomicCls('cw')} {$fieldHelpers->getCustomClasses('cw')}"
90 {$fieldHelpers->getCustomAttributes('cw')}
91 >
92 <input
93 id="{$rowID}-chk-{$optCount}"
94 data-oopt="{$rowID}"
95 type="radio"
96 class="{$fieldHelpers->getAtomicCls('ci')} {$fieldHelpers->getCustomClasses('ci')}"
97 value=""
98 {$check}
99 {$name}
100 {$fieldHelpers->getCustomAttributes('ci')}
101 />
102 <label
103 data-cl
104 for="{$rowID}-chk-{$optCount}"
105 class="{$fieldHelpers->getAtomicCls('cl')} {$fieldHelpers->getCustomClasses('cl')}"
106 {$fieldHelpers->getCustomAttributes('cl')}
107 >
108 <span
109 data-bx
110 class="{$fieldHelpers->getAtomicCls('bx')} {$fieldHelpers->getAtomicCls('rdo')} {$fieldHelpers->getCustomClasses('rdo')}"
111 {$fieldHelpers->getCustomAttributes('rdo')}
112 >
113 <svg width="12" height="10" viewBox="0 0 12 10" class="{$fieldHelpers->getAtomicCls('svgwrp')} {$fieldHelpers->getCustomClasses('svgwrp')}">
114 <use data-ck-icn href=#{$rowID}-ck-svg class="{$fieldHelpers->getAtomicCls('ck-icn')} {$fieldHelpers->getCustomClasses('ck-icn')}" />
115 </svg>
116 </span>
117 <span
118 class="{$fieldHelpers->getAtomicCls('ct')} {$fieldHelpers->getCustomClasses('ct')}"
119 {$fieldHelpers->getCustomAttributes('ct')}
120 >
121 Other..
122 </span>
123 </label>
124 <div data-oinp-wrp class="{$fieldHelpers->getAtomicCls('other-inp-wrp')}">
125 <input
126 data-bf-other-inp="{$rowID}-chk-{$optCount}"
127 type="text"
128 class="{$fieldHelpers->getAtomicCls('other-inp')}"
129 {$inpReq}
130 placeholder="{$inputPh}"
131 >
132 </div>
133 </div>
134 RADIOBOXOPTIONS;
135 }
136
137 return <<<RADIOBOX
138 <div
139 class="{$fieldHelpers->getAtomicCls('cc')} {$fieldHelpers->getCustomClasses('cc')}"
140 {$fieldHelpers->getCustomAttributes('cc')}
141 >
142 {$radioBoxOptions}
143 </div>
144 RADIOBOX;
145 }
146 }
147