PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.2.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.2.2
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 / TextField.php

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

123 lines 3.5 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 TextField
8 {
9 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
10 {
11 if (!is_object($field)) {
12 return '';
13 }
14 $inputWrapper = new ClassicInputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
15 $input = self::field($field, $rowID, $form_atomic_Cls_map, $value, $formID);
16 return $inputWrapper->wrapper($input);
17 }
18
19 private static function field($field, $rowID, $form_atomic_Cls_map, $value, $formID = null)
20 {
21 $fieldHelpers = new ClassicFieldHelpers($field, $rowID, $form_atomic_Cls_map, $formID);
22
23 $prefixIcn = $fieldHelpers->icon('prefixIcn', 'pre-i');
24 $suffixIcn = $fieldHelpers->icon('suffixIcn', 'suf-i');
25 $req = $fieldHelpers->required();
26 $disabled = $fieldHelpers->disabled();
27 $readonly = $fieldHelpers->readonly();
28 $inputMode = apply_filters('bitform_field_inputmode_attr', '', $field);
29 $name = $fieldHelpers->name();
30 $ac = $fieldHelpers->autocomplete();
31 $mx = apply_filters('bitform_field_max_attr', '', $field);
32 $mn = apply_filters('bitform_field_min_attr', '', $field);
33 $minlength = $fieldHelpers->minlength();
34 $maxlength = $fieldHelpers->maxlength();
35 $maxword = $fieldHelpers->maxword();
36 $minword = $fieldHelpers->minword();
37 $ph = $fieldHelpers->placeholder();
38 $value = $fieldHelpers->value();
39 $ariaDescribedBy = $fieldHelpers->ariaDescribedBy();
40 $ariaRequired = $fieldHelpers->ariaRequired();
41 $list = '';
42 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
43 $contentCount = count($bfFrontendFormIds);
44 $sugg = apply_filters('bitform_field_suggestions_datalist', '', $field, $rowID, $contentCount);
45
46 $showPickerAttr = self::showPickerAttr($field);
47
48 if (is_object($field) && property_exists($field, 'suggestions') && is_countable($field->suggestions) && count($field->suggestions) > 0) {
49 $list = "list='{$rowID}-{$contentCount}-datalist'";
50 }
51
52 return sprintf(
53 '<div %1$s class="%2$s %3$s">
54 <input
55 %4$s
56 id="%5$s"
57 %6$s
58 class="%7$s %8$s"
59 type="%9$s"
60 %10$s
61 %11$s
62 %12$s
63 %13$s
64 %14$s
65 %15$s
66 %16$s
67 %17$s
68 %18$s
69 %19$s
70 %20$s
71 %21$s
72 %22$s
73 %23$s
74 %24$s
75 %25$s
76 %26$s
77 />
78 %27$s
79 %28$s
80 </div>
81 %29$s',
82 $fieldHelpers->getCustomAttributes('inp-fld-wrp'),
83 $fieldHelpers->getAtomicCls('inp-fld-wrp'),
84 $fieldHelpers->getCustomClasses('inp-fld-wrp'),
85 $fieldHelpers->getCustomAttributes('fld'),
86 "{$rowID}-{$contentCount}",
87 $list,
88 $fieldHelpers->getAtomicCls('fld'),
89 $fieldHelpers->getCustomClasses('fld'),
90 esc_attr($field->typ),
91 $req,
92 $ariaRequired,
93 $ariaDescribedBy,
94 $disabled,
95 $readonly,
96 $ph,
97 $mn,
98 $mx,
99 $minlength,
100 $maxlength,
101 $maxword,
102 $minword,
103 $ac,
104 $inputMode,
105 $name,
106 $value,
107 $showPickerAttr,
108 $prefixIcn,
109 $suffixIcn,
110 $sugg
111 );
112 }
113
114 private static function showPickerAttr($field)
115 {
116 $dateType = ['date', 'datetime-local', 'month', 'time', 'week'];
117 if (in_array($field->typ, $dateType, true)) {
118 return 'data-bf-show-picker="1"';
119 }
120 return '';
121 }
122 }
123