PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 1.5.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v1.5.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 / ThemeBase.php

ThemeBase.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 1.5.2, at includes/Frontend/Form/View/Theme/ThemeBase.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;
4 use BitCode\BitForm\Core\Util\FieldValueHandler;
5
6 class ThemeBase
7 {
8 public function inputWrapper($field, $rowID, $field_name, $error = null, $value = null, $formID = null)
9 {
10 $isHidden = !empty($field->valid->hide) && $field->valid->hide ? 'vis-n' : null;
11 $isReqSym = empty($field->valid->req) ? null : ' <span class="fld-req-symbol">*</span>';
12 $noLabel = ['decision-box', 'html', 'button', 'paypal', 'razorpay', 'recaptcha'];
13 $fieldLbl = "";
14
15 if(!in_array($field->typ, $noLabel) && isset($field->lbl)){
16 $replaceToBackslash = str_replace('$_bf_$','\\', $field->lbl);
17 $fieldLbl = FieldValueHandler::replaceSmartTagWithValue($replaceToBackslash);
18 }
19
20 if(isset($field->ph)){
21 $phReplaceToBackslash = str_replace('$_bf_$','\\', $field->ph);
22 $field->ph = FieldValueHandler::replaceSmartTagWithValue($phReplaceToBackslash);
23 }
24
25
26 $lbl = (!in_array($field->typ, $noLabel) && !isset($field->valid->hideLbl) && isset($field->lbl)) ? "<label class='fld-lbl fld-lbl-$formID' for='$rowID'>" . esc_html($fieldLbl) . $isReqSym . "</label>" : "";
27
28 $err = (isset($error) && !empty($error)) ? $error : "";
29 $errStyle = !empty($err) ? "style='height: auto'" : "";
30 $fieldHTML = $this->getField($field, $rowID, $field_name, $error, $value, $formID);
31 $errHTML = '';
32 if ($err || isset($field->err)) {
33 $errHTML = <<<ERRORHTML
34 <div class="error-wrapper" $errStyle>
35 <div id="$rowID-error" class="error-txt">$err</div>
36 </div>
37 ERRORHTML;
38 }
39
40 return <<<INPUTWRAPPER
41 <div class="btcd-fld-itm $rowID $isHidden">
42 <div class="fld-wrp fld-wrp-$formID drag">
43 $lbl
44 $fieldHTML
45 $errHTML
46 </div>
47 </div>
48 INPUTWRAPPER;
49 }
50
51 protected function getField($field, $rowID, $field_name, $error = null, $value = null, $formID = null)
52 {
53 switch ($field->typ) {
54 case 'text':
55 case 'username':
56 case 'number':
57 case 'password':
58 case 'email':
59 case 'url':
60 case 'date':
61 case 'datetime-local':
62 case 'time':
63 case 'month':
64 case 'week':
65 case 'color':
66 return $this->textField($field, $rowID, $field_name, $formID, $error, $value);
67 case 'textarea':
68 return $this->textArea($field, $rowID, $field_name, $formID, $error, $value);
69 case 'check':
70 return $this->checkBox($field, $rowID, $field_name, $formID, $error, $value);
71 case 'radio':
72 return $this->radioBox($field, $rowID, $field_name, $formID, $error, $value);
73 case 'select':
74 return $this->dropDown($field, $rowID, $field_name, $formID, $error, $value);
75 case 'file-up':
76 return $this->fileUp($field, $rowID, $field_name, $formID, $error, $value);
77 case 'recaptcha':
78 return $this->recaptcha($field, $rowID, $field_name, $formID, $error, $value);
79 case 'decision-box':
80 return $this->decisionBox($field, $rowID, $field_name, $formID, $error, $value);
81 case 'html':
82 return $this->html($field, $rowID, $field_name, $formID, $error, $value);
83 case 'paypal':
84 return $this->paypal($field, $rowID, $field_name, $formID, $error, $value);
85 case 'razorpay':
86 return $this->razorPay($field, $rowID, $field_name, $formID, $error, $value);
87 case 'submit':
88 return $this->submitBtns($field, $rowID, $field_name, $formID, $error, $value);
89 case 'button':
90 return $this->button($field, $rowID, $field_name, $formID, $error, $value);
91 default:
92 break;
93 }
94 }
95
96 protected function setTag($tag, $value, $attr = null)
97 {
98 echo "<$tag $attr>" . esc_html($value) . "</$tag>";
99 }
100
101 protected function setAttribute($attr, $value = null)
102 {
103 echo " $attr='" . esc_attr($value) . "' ";
104 }
105 protected function setSingleValuedAttribute($attr)
106 {
107 echo " $attr ";
108 }
109 }
110