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

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

95 lines 3.1 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 InputWrapper($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 FieldHelpers($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 <<<BUTTONFIELD
53 <div
54 {$fieldHelpers->getCustomAttributes('inp-fld-wrp')}
55 class="{$fieldHelpers->getAtomicCls('inp-fld-wrp')} {$fieldHelpers->getCustomClasses('inp-fld-wrp')}"
56 >
57 <button
58 {$fieldHelpers->getCustomAttributes('btn')}
59 class="{$fieldHelpers->getAtomicCls('btn')} {$fieldHelpers->getCustomClasses('btn')} {$btnClass}"
60 type="{$btnTyp}"
61 {$name}
62 {$disabled}
63 >
64 {$btnPreIcn}
65 {$fieldHelpers->kses_post($fieldHelpers->renderHTMR($field->txt))}
66 {$btnSufIcn}
67 {$btnSpinner}
68 </button>
69 </div>
70 BUTTONFIELD;
71 }
72
73 private static function helperTxt($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
74 {
75 $fieldHelpers = new FieldHelpers($field, $rowID, $form_atomic_Cls_map);
76 $hlpPreIcn = $fieldHelpers->icon('hlpPreIcn', 'hlp-txt-pre-i');
77 $hlpSufIcn = $fieldHelpers->icon('hlpSufIcn', 'hlp-txt-suf-i');
78 $hlpTxt = isset($field->helperTxt) ? $fieldHelpers->renderHTMR($field->helperTxt) : '';
79
80 $helperTxt = <<<HELPERTXT
81 <div
82 {$fieldHelpers->getCustomAttributes('hlp-txt')}
83 class="{$fieldHelpers->getAtomicCls('hlp-txt')} {$fieldHelpers->getCustomClasses('hlp-txt')}"
84 >
85 {$hlpPreIcn}
86 {$fieldHelpers->kses_post($hlpTxt)}
87 {$hlpSufIcn}
88 </div>
89
90 HELPERTXT;
91
92 return property_exists($field, 'helperTxt') ? $helperTxt : '';
93 }
94 }
95