PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.21.13
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.21.13
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 / SliderField.php

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

110 lines 3.9 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 use BitCode\BitForm\Core\Util\FrontendHelpers;
6
7 class SliderField
8 {
9 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
10 {
11 $inputWrapper = new ClassicInputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
12 $input = self::field($field, $rowID, $form_atomic_Cls_map, $value);
13 return $inputWrapper->wrapper($input);
14 }
15
16 private static function field($field, $rowID, $form_atomic_Cls_map, $value)
17 {
18 $fieldHelpers = new ClassicFieldHelpers($field, $rowID, $form_atomic_Cls_map);
19
20 $prefixIcn = $fieldHelpers->icon('prefixIcn', 'pre-i');
21 $suffixIcn = $fieldHelpers->icon('suffixIcn', 'suf-i');
22 $sugg = '';
23 $req = $fieldHelpers->required();
24 $disabled = $fieldHelpers->disabled();
25 $readonly = $fieldHelpers->readonly();
26 $inputMode = '';
27 $name = $fieldHelpers->name();
28 $ac = $fieldHelpers->autocomplete();
29 $mx = '';
30 $mn = '';
31 $step = '';
32 $ph = $fieldHelpers->placeholder();
33 $value = $fieldHelpers->value();
34 $list = '';
35 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
36 $contentCount = count($bfFrontendFormIds);
37
38 if (property_exists($field, 'suggestions') && count($field->suggestions) > 0) {
39 $list = "list='{$rowID}-{$contentCount}-datalist'";
40 $sugg .= "<datalist id='{$rowID}-{$contentCount}-datalist'>";
41 foreach ($field->suggestions as $suggestion) {
42 $val = (isset($suggestion->val) && !empty($suggestion->val)) ? $suggestion->val : $suggestion->lbl;
43 $sugg .= "<option value='{$fieldHelpers->esc_attr($val)}'>{$fieldHelpers->esc_html($suggestion->lbl)}</option>";
44 }
45 $sugg .= '</datalist>';
46 }
47
48 if (property_exists($field, 'mn') && '' !== $field->mn) {
49 $mn = "min='{$fieldHelpers->esc_attr($field->mn)}'";
50 }
51
52 if (property_exists($field, 'mx') && '' !== $field->mx) {
53 $mx = "max='{$fieldHelpers->esc_attr($field->mx)}'";
54 }
55
56 if (property_exists($field, 'step') && '' !== $field->step) {
57 $step = "step='{$fieldHelpers->esc_attr($field->step)}'";
58 }
59
60 if (property_exists($field, 'inputMode') && '' !== $field->inputMode) {
61 $inputMode = "inputMode='{$fieldHelpers->esc_attr($field->inputMode)}'";
62 }
63
64 $minValue = property_exists($field, 'mn') ? $field->mn : 0;
65 $maxValue = property_exists($field, 'mx') ? $field->mx : 100;
66
67 $defaultVal = (($maxValue - $minValue) / 2) + $minValue;
68 if ($fieldHelpers->property_exists_nested($field, 'val', '', 1)) {
69 $defaultVal = $field->val;
70 } elseif ($fieldHelpers->property_exists_nested($field, 'defaultValue', '', 1)) {
71 $defaultVal = $field->defaultValue;
72 }
73
74 $lowerTrackPercentage = ($defaultVal - $minValue) / ($maxValue - $minValue) * 100;
75
76 $wrpperStyle = "style='--bfv-fld-val: \"{$defaultVal}\";'";
77 $inputStyle = "style='--bfv-fill-lower-track: {$lowerTrackPercentage}% !important;'";
78
79 return ' <div
80 ' . $fieldHelpers->getCustomAttributes('inp-fld-wrp') . '
81 class="' . $fieldHelpers->getAtomicCls('inp-fld-wrp') . ' ' . $fieldHelpers->getCustomClasses('inp-fld-wrp') . '"
82 ' . $wrpperStyle . '
83 >
84 <input
85 ' . $fieldHelpers->getCustomAttributes('fld') . '
86 id="' . $rowID . '-' . $contentCount . '"
87 ' . $list . '
88 class="' . $fieldHelpers->getAtomicCls('fld') . ' ' . $fieldHelpers->getCustomClasses('fld') . '"
89 type="' . $field->typ . '"
90 ' . $req . '
91 ' . $disabled . '
92 ' . $readonly . '
93 ' . $ph . '
94 ' . $mn . '
95 ' . $mx . '
96 ' . $step . '
97 ' . $ac . '
98 ' . $inputMode . '
99 ' . $name . '
100 ' . $value . '
101 ' . $inputStyle . '
102 />
103 ' . $prefixIcn . '
104 ' . $suffixIcn . '
105 <span class="' . $fieldHelpers->getAtomicCls('slider-val') . '">Value : </span>
106 </div>
107 ' . $sugg . "\n";
108 }
109 }
110