PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.9.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.9.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 2.10.2 All 137 releases
bit-form / includes / Frontend / Form / View / Theme / Fields / CurrencyField.php

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

218 lines 7.3 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 CurrencyField
6 {
7 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = '')
8 {
9 $inputWrapper = new InputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
10 $input = self::field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
11 return $inputWrapper->wrapper($input);
12 }
13
14 private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = '')
15 {
16 $fh = new FieldHelpers($field, $rowID, $form_atomic_Cls_map);
17 $img_url = BITFORMS_ASSET_URI . '/../static/currencies/';
18
19 $req = $fh->required();
20 $disabled = $fh->disabled();
21 $readonly = $fh->readonly();
22 $name = $fh->name();
23 $ph = $fh->placeholder();
24 $selectedFlagImage = '';
25 $tabIndx = isset($field->disabled) ? -1 : 0;
26 $selectedCurrencyClearable = '';
27 $searchPlaceholder = '';
28 $searchClearable = '';
29 $options = '';
30 $readonlyCls = isset($field->readonly) ? 'readonly' : '';
31 $disabledCls = isset($field->disabled) ? 'disabled' : '';
32 $value = is_string($value) ? $value : '';
33 $numValue = preg_replace('/[^0-9.-]/', '', $value);
34
35 $img = htmlentities("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'/>");
36
37 if ($fh->property_exists_nested($field, 'config->selectedFlagImage', true)) {
38 $selectedFlagImage = <<<FLAGIMAGE
39 <div class="{$fh->getAtomicCls('selected-currency-wrp')}">
40 <img
41 {$fh->getCustomAttributes('selected-currency-img')}
42 class="{$fh->getAtomicCls('selected-currency-img')} {$fh->getCustomClasses('selected-currency-img')}"
43 aria-hidden="true"
44 alt="selected country flag"
45 src="{$img}"
46 />
47 </div>
48 FLAGIMAGE;
49 }
50
51 if ($fh->property_exists_nested($field, 'config->selectedCurrencyClearable', true)) {
52 $selectedCurrencyClearable = <<<CLEARABLE
53 <button
54 {$fh->getCustomAttributes('input-clear-btn')}
55 type="button"
56 title="Clear selected currency value"
57 class="{$fh->getAtomicCls('input-clear-btn')} {$fh->getCustomClasses('input-clear-btn')}"
58 >
59 <svg
60 width="12"
61 height="12"
62 role="img"
63 title="Cross icon"
64 viewBox="0 0 24 24"
65 fill="none"
66 stroke="currentColor"
67 stroke-width="2"
68 stroke-linecap="round"
69 stroke-linejoin="round"
70 >
71 <line x1="18" y1="6" x2="6" y2="18" />
72 <line x1="6" y1="6" x2="18" y2="18" />
73 </svg>
74 </button>
75 CLEARABLE;
76 }
77
78 if ($fh->property_exists_nested($field, 'config->searchPlaceholder', '', 1)) {
79 $searchPlaceholder = "placeholder='{$fh->esc_attr($field->config->searchPlaceholder)}'";
80 }
81
82 if ($fh->property_exists_nested($field, 'config->searchClearable', true)) {
83 $searchClearable = <<<CLEARABLE
84 <button
85 {$fh->getCustomAttributes('search-clear-btn')}
86 type="button"
87 title="Clear search"
88 class="{$fh->getAtomicCls('search-clear-btn')} {$fh->getCustomClasses('search-clear-btn')}"
89 tabIndex="-1"
90 >
91 <svg
92 width="12"
93 height="12"
94 role="img"
95 title="Cross icon"
96 viewBox="0 0 24 24"
97 fill="none"
98 stroke="currentColor"
99 stroke-width="2"
100 stroke-linecap="round"
101 stroke-linejoin="round"
102 >
103 <line x1="18" y1="6" x2="6" y2="18" />
104 <line x1="6" y1="6" x2="18" y2="18" />
105 </svg>
106 </button>
107 CLEARABLE;
108 }
109
110 return <<<CURRENCYFIELD
111 <div class="{$fh->getAtomicCls('currency-fld-container')}">
112 <div
113 {$fh->getCustomAttributes('currency-fld-wrp')}
114 class="{$fh->getAtomicCls('currency-fld-wrp')} {$fh->getCustomClasses('currency-fld-wrp')} {$disabled} {$readonly}"
115 >
116 <input
117 {$fh->getCustomAttributes('currency-hidden-input')}
118 {$name}
119 {$req}
120 type="text"
121 title="Currency Hidden Input"
122 class="{$fh->getAtomicCls('currency-hidden-input')} d-none"
123 {$disabled}
124 {$readonly}
125 value="{$fh->esc_attr($value)}"
126 />
127 <div class="{$fh->getAtomicCls('currency-inner-wrp')}">
128 <div
129 {$fh->getCustomAttributes('dpd-wrp')}
130 class="{$fh->getAtomicCls('dpd-wrp')} {$fh->getCustomClasses('dpd-wrp')}"
131 role="combobox"
132 aria-controls="currency-dropdown"
133 aria-live="assertive"
134 aria-labelledby="currency-label-2"
135 aria-expanded="false"
136 tabIndex="{$tabIndx}"
137 >
138 {$selectedFlagImage}
139 <div class="{$fh->getAtomicCls('dpd-down-btn')}">
140 <svg
141 width="15"
142 height="15"
143 role="img"
144 title="Downarrow icon"
145 viewBox="0 0 24 24"
146 fill="none"
147 stroke="currentColor"
148 stroke-width="2"
149 stroke-linecap="round"
150 stroke-linejoin="round"
151 >
152 <polyline points="6 9 12 15 18 9" />
153 </svg>
154 </div>
155 </div>
156 <input
157 {$fh->getCustomAttributes('currency-amount-input')}
158 aria-label="Currency Input"
159 type="text"
160 class="{$fh->getAtomicCls('currency-amount-input')} {$fh->getCustomClasses('currency-amount-input')}"
161 {$ph}
162 tabIndex="{$tabIndx}"
163 data-num-value="{$numValue}"
164 />
165 {$selectedCurrencyClearable}
166 </div>
167 <div
168 {$fh->getCustomAttributes('option-wrp')}
169 class="{$fh->getAtomicCls('option-wrp')} {$fh->getCustomClasses('option-wrp')}"
170 >
171 <div class="{$fh->getAtomicCls('option-inner-wrp')}">
172 <div
173 {$fh->getCustomAttributes('option-search-wrp')}
174 class="{$fh->getAtomicCls('option-search-wrp')} {$fh->getCustomClasses('option-search-wrp')}"
175 >
176 <input
177 {$fh->getCustomAttributes('opt-search-input')}
178 type="search"
179 class="{$fh->getAtomicCls('opt-search-input')} {$fh->getCustomClasses('opt-search-input')}"
180 {$searchPlaceholder}
181 autoComplete="off"
182 tabIndex="-1"
183 />
184 <svg
185 {$fh->getCustomAttributes('opt-search-icn')}
186 class="{$fh->getAtomicCls('opt-search-icn')} {$fh->getCustomClasses('opt-search-icn')}"
187 aria-hidden="true"
188 width="22"
189 height="22"
190 viewBox="0 0 24 24"
191 fill="none"
192 stroke="currentColor"
193 stroke-width="2"
194 stroke-linecap="round"
195 stroke-linejoin="round"
196 >
197 <circle cx="11" cy="11" r="8" />
198 <line x1="21" y1="21" x2="16.65" y2="16.65" />
199 </svg>
200 {$searchClearable}
201 </div>
202 <ul
203 {$fh->getCustomAttributes('option-list')}
204 class="{$fh->getAtomicCls('option-list')} {$fh->getCustomClasses('option-list')}"
205 tabIndex="-1"
206 role="listbox"
207 aria-label="currency list"
208 >
209 {$options}
210 </ul>
211 </div>
212 </div>
213 </div>
214 </div>
215 CURRENCYFIELD;
216 }
217 }
218