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 / ButtonField.php

ButtonField.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/ButtonField.php

114 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 class ButtonField
6 {
7 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
8 {
9 $inputWrapper = new ClassicInputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
10 $button = self::field($field, $rowID, $form_atomic_Cls_map, $formID);
11 return $inputWrapper->wrapper($button, true, true);
12 }
13
14 private static function getBtnClass($btnTyp)
15 {
16 switch ($btnTyp) {
17 case 'save-draft':
18 return 'bf-trigger-form-abandonment';
19 case 'next-step':
20 return 'next-step-btn';
21 case 'previous-step':
22 return 'prev-step-btn';
23 }
24 return '';
25 }
26
27 private static function getBtnTyp($btnTyp)
28 {
29 switch ($btnTyp) {
30 case 'submit':
31 case 'reset':
32 return $btnTyp;
33 default:
34 return 'button';
35 }
36 }
37
38 private static function field($field, $rowID, $form_atomic_Cls_map, $formID, $error = null, $value = null)
39 {
40 $fieldHelpers = new ClassicFieldHelpers($field, $rowID, $form_atomic_Cls_map);
41 // $helperTxt = self::helperTxt($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null);
42
43 $btnPreIcn = $fieldHelpers->icon('btnPreIcn', 'btn-pre-i');
44 $btnSufIcn = $fieldHelpers->icon('btnSufIcn', 'btn-suf-i');
45 $disabled = $fieldHelpers->disabled();
46 // $name = $field->btnTyp === 'submit' ? 'name="bit-form-submit-btn"' : '';
47 $name = $fieldHelpers->name();
48 $btnSpinner = '<span class="bf-spinner d-none"></span>';
49 $btnClass = self::getBtnClass($field->btnTyp);
50 $btnTyp = self::getBtnTyp($field->btnTyp);
51
52 return sprintf(
53 '<div
54 %1$s
55 class="%2$s %3$s"
56 >
57 <button
58 %4$s
59 class="%5$s %6$s %7$s"
60 type="%8$s"
61 %9$s
62 %10$s
63 >
64 %11$s
65 %12$s
66 %13$s
67 %14$s
68 </button>
69 </div>',
70 $fieldHelpers->getCustomAttributes('inp-fld-wrp'), // 1
71 $fieldHelpers->getAtomicCls('inp-fld-wrp'), // 2
72 $fieldHelpers->getCustomClasses('inp-fld-wrp'), // 3
73 $fieldHelpers->getCustomAttributes('btn'), // 4
74 $fieldHelpers->getAtomicCls('btn'), // 5
75 $fieldHelpers->getCustomClasses('btn'), // 6
76 $btnClass, // 7
77 $btnTyp, // 8
78 $name, // 9
79 $disabled, // 10
80 $btnPreIcn, // 11
81 $fieldHelpers->kses_post($fieldHelpers->renderHTMR($field->txt)), // 12
82 $btnSufIcn, // 13
83 $btnSpinner // 14
84 );
85 }
86
87 private static function helperTxt($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
88 {
89 $fieldHelpers = new ClassicFieldHelpers($field, $rowID, $form_atomic_Cls_map);
90 $hlpPreIcn = $fieldHelpers->icon('hlpPreIcn', 'hlp-txt-pre-i');
91 $hlpSufIcn = $fieldHelpers->icon('hlpSufIcn', 'hlp-txt-suf-i');
92 $hlpTxt = isset($field->helperTxt) ? $fieldHelpers->renderHTMR($field->helperTxt) : '';
93
94 $helperTxt = sprintf(
95 '<div
96 %1$s
97 class="%2$s %3$s"
98 >
99 %4$s
100 %5$s
101 %6$s
102 </div>',
103 $fieldHelpers->getCustomAttributes('hlp-txt'),
104 $fieldHelpers->getAtomicCls('hlp-txt'),
105 $fieldHelpers->getCustomClasses('hlp-txt'),
106 $hlpPreIcn,
107 $fieldHelpers->kses_post($hlpTxt),
108 $hlpSufIcn
109 );
110
111 return property_exists($field, 'helperTxt') ? $helperTxt : '';
112 }
113 }
114