PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
V3.3.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 All 139 releases
← All changes | includes/Frontend/Form/View/Theme/Fields/TextField.php +61 -82 3.3.1 → 2.15.3 View file →
@@ -7,116 +7,95 @@
7 7 class TextField
8 8 {
9 9 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
10 10 {
11 - if (!is_object($field)) {
12 - return '';
13 - }
14 11 $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);
12 + $input = self::field($field, $rowID, $form_atomic_Cls_map, $value);
16 13 return $inputWrapper->wrapper($input);
17 14 }
18 15
19 - private static function field($field, $rowID, $form_atomic_Cls_map, $value, $formID = null)
16 + private static function field($field, $rowID, $form_atomic_Cls_map, $value)
20 17 {
21 - $fieldHelpers = new ClassicFieldHelpers($field, $rowID, $form_atomic_Cls_map, $formID);
18 + $fieldHelpers = new ClassicFieldHelpers($field, $rowID, $form_atomic_Cls_map);
22 19
23 20 $prefixIcn = $fieldHelpers->icon('prefixIcn', 'pre-i');
24 21 $suffixIcn = $fieldHelpers->icon('suffixIcn', 'suf-i');
22 + $sugg = '';
25 23 $req = $fieldHelpers->required();
26 24 $disabled = $fieldHelpers->disabled();
27 25 $readonly = $fieldHelpers->readonly();
28 - $inputMode = apply_filters('bitform_field_inputmode_attr', '', $field);
26 + $inputMode = '';
29 27 $name = $fieldHelpers->name();
30 28 $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();
29 + $mx = '';
30 + $mn = '';
37 31 $ph = $fieldHelpers->placeholder();
38 32 $value = $fieldHelpers->value();
39 - $ariaDescribedBy = $fieldHelpers->ariaDescribedBy();
40 - $ariaRequired = $fieldHelpers->ariaRequired();
41 33 $list = '';
42 34 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
43 35 $contentCount = count($bfFrontendFormIds);
44 - $sugg = apply_filters('bitform_field_suggestions_datalist', '', $field, $rowID, $contentCount);
45 36
46 - $showPickerAttr = self::showPickerAttr($field);
37 + $onClickAttr = self::onClickAttr($field, $rowID);
47 38
48 - if (is_object($field) && property_exists($field, 'suggestions') && is_countable($field->suggestions) && count($field->suggestions) > 0) {
39 + if (property_exists($field, 'suggestions') && count($field->suggestions) > 0) {
49 40 $list = "list='{$rowID}-{$contentCount}-datalist'";
41 + $sugg .= "<datalist id='{$rowID}-{$contentCount}-datalist'>";
42 + foreach ($field->suggestions as $suggestion) {
43 + $val = (isset($suggestion->val) && !empty($suggestion->val)) ? $suggestion->val : $suggestion->lbl;
44 + $sugg .= "<option value='{$fieldHelpers->esc_attr($val)}'>{$fieldHelpers->esc_html($suggestion->lbl)}</option>";
45 + }
46 + $sugg .= '</datalist>';
50 47 }
51 48
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 - );
49 + if (property_exists($field, 'mn') && '' !== $field->mn) {
50 + $mn = "min='{$fieldHelpers->esc_attr($field->mn)}'";
51 + }
52 +
53 + if (property_exists($field, 'mx') && '' !== $field->mx) {
54 + $mx = "max='{$fieldHelpers->esc_attr($field->mx)}'";
55 + }
56 +
57 + if (property_exists($field, 'inputMode') && '' !== $field->inputMode) {
58 + $inputMode = "inputMode='{$fieldHelpers->esc_attr($field->inputMode)}'";
59 + }
60 +
61 + return <<<TEXTFIELD
62 + <div
63 + {$fieldHelpers->getCustomAttributes('inp-fld-wrp')}
64 + class="{$fieldHelpers->getAtomicCls('inp-fld-wrp')} {$fieldHelpers->getCustomClasses('inp-fld-wrp')}"
65 + >
66 + <input
67 + {$fieldHelpers->getCustomAttributes('fld')}
68 + id="{$rowID}-{$contentCount}"
69 + {$list}
70 + class="{$fieldHelpers->getAtomicCls('fld')} {$fieldHelpers->getCustomClasses('fld')}"
71 + type="{$field->typ}"
72 + {$req}
73 + {$disabled}
74 + {$readonly}
75 + {$ph}
76 + {$mn}
77 + {$mx}
78 + {$ac}
79 + {$inputMode}
80 + {$name}
81 + {$value}
82 + {$onClickAttr}
83 + />
84 + {$prefixIcn}
85 + {$suffixIcn}
86 + </div>
87 + {$sugg}
88 +TEXTFIELD;
112 89 }
113 90
114 - private static function showPickerAttr($field)
91 + private static function onClickAttr($field, $rowID)
115 92 {
93 + $onClickAttr = '';
116 94 $dateType = ['date', 'datetime-local', 'month', 'time', 'week'];
117 - if (in_array($field->typ, $dateType, true)) {
118 - return 'data-bf-show-picker="1"';
95 + //field type check
96 + if (in_array($field->typ, $dateType)) {
97 + $onClickAttr = "onclick='this.showPicker();'";
119 98 }
120 - return '';
99 + return $onClickAttr;
121 100 }
122 101 }