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

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

139 lines 5.2 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\Frontend\Form\View\Theme\ThemeBase;
6
7 class RepeaterField
8 {
9 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $formViewerInstance, $nestedLayout, $error = null, $value = null)
10 {
11 $inputWrapper = new InputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
12 $input = self::field($field, $rowID, $formID, $formViewerInstance, $nestedLayout, $form_atomic_Cls_map, $value);
13 return $inputWrapper->wrapper($input);
14 }
15
16 private static function field($field, $rowID, $formID, $formViewerInstance, $nestedLayout, $form_atomic_Cls_map, $value)
17 {
18 $fieldHelpers = new FieldHelpers($field, $rowID, $form_atomic_Cls_map);
19
20 $addBtnMarkup = '';
21 $addToEndBtnMarkup = '';
22
23 if (isset($field->addBtn->show) && $field->addBtn->show) {
24 $addBtnPreIcn = $fieldHelpers->icon('addBtnPreIcn', 'rpt-add-btn-pre-i');
25 $addBtnSufIcn = $fieldHelpers->icon('addBtnSufIcn', 'rpt-add-btn-suf-i');
26 $addBtnMarkup = <<<ADDBTN
27 <button
28 {$fieldHelpers->getCustomAttributes('rpt-add-btn')}
29 class="{$fieldHelpers->getAtomicCls('rpt-add-btn')} {$fieldHelpers->getCustomClasses('rpt-add-btn')}"
30 type="{$field->addBtn->btnTyp}"
31 >
32 {$addBtnPreIcn}
33 {$fieldHelpers->kses_post($fieldHelpers->renderHTMR($field->addBtn->txt))}
34 {$addBtnSufIcn}
35 </button>
36 ADDBTN;
37 };
38
39 if (isset($field->addToEndBtn->show) && $field->addToEndBtn->show) {
40 $addToEndBtnPreIcn = $fieldHelpers->icon('addToEndBtnPreIcn', 'add-to-end-btn-pre-i');
41 $addToEndBtnSufIcn = $fieldHelpers->icon('addToEndBtnSufIcn', 'add-to-end-btn-suf-i');
42 $addToEndBtnMarkup = <<<ADDTOENDBTN
43 <div
44 {$fieldHelpers->getCustomAttributes('add-to-end-btn-wrp')}
45 class="{$fieldHelpers->getAtomicCls('add-to-end-btn-wrp')} {$fieldHelpers->getCustomClasses('add-to-end-btn-wrp')}"
46 >
47 <button
48 {$fieldHelpers->getCustomAttributes('add-to-end-btn')}
49 class="{$fieldHelpers->getAtomicCls('add-to-end-btn')} {$fieldHelpers->getCustomClasses('add-to-end-btn')}"
50 type="{$field->addToEndBtn->btnTyp}"
51 >
52 {$addToEndBtnPreIcn}
53 {$fieldHelpers->kses_post($fieldHelpers->renderHTMR($field->addToEndBtn->txt))}
54 {$addToEndBtnSufIcn}
55 </button>
56 </div>
57 ADDTOENDBTN;
58 };
59
60 $removeBtnPreIcn = $fieldHelpers->icon('removeBtnPreIcn', 'rpt-rmv-btn-pre-i');
61 $removeBtnSufIcn = $fieldHelpers->icon('removeBtnSufIcn', 'rpt-rmv-btn-suf-i');
62
63 $themeBase = new ThemeBase();
64 $fieldHtml = '';
65 if (isset($nestedLayout->lg)) {
66 foreach ($nestedLayout->lg as $row) {
67 $fieldHtml .= $themeBase->inputWrapper($formViewerInstance, $row->i);
68 }
69 }
70
71 $repeatableWrap = <<<RPTABLEWRAP
72 <div
73 {$fieldHelpers->getCustomAttributes('rpt-wrp')}
74 class="{$fieldHelpers->getAtomicCls('rpt-wrp')} {$fieldHelpers->getCustomClasses('rpt-wrp')}"
75 >
76 <div
77 {$fieldHelpers->getCustomAttributes('rpt-grid-wrp')}
78 class="{$fieldHelpers->getAtomicCls('rpt-grid-wrp')} {$fieldHelpers->getCustomClasses('rpt-grid-wrp')}"
79 >
80 <div class="_frm-b{$formID} repeater-grid">
81 {$fieldHtml}
82 </div>
83 </div>
84 <div
85 {$fieldHelpers->getCustomAttributes('pair-btn-wrp')}
86 class="{$fieldHelpers->getAtomicCls('pair-btn-wrp')} {$fieldHelpers->getCustomClasses('pair-btn-wrp')}"
87 >
88 {$addBtnMarkup}
89 <button
90 {$fieldHelpers->getCustomAttributes('rpt-rmv-btn')}
91 class="{$fieldHelpers->getAtomicCls('rpt-rmv-btn')} {$fieldHelpers->getCustomClasses('rpt-rmv-btn')}"
92 type="{$field->removeBtn->btnTyp}"
93 >
94 {$removeBtnPreIcn}
95 {$fieldHelpers->renderHTMR($field->removeBtn->txt)}
96 {$removeBtnSufIcn}
97 </button>
98 </div>
99 </div>
100 RPTABLEWRAP;
101
102 $defaultRow = isset($field->defaultRow) ? intval($field->defaultRow) : 1;
103 if (isset($field->maxRow) && $defaultRow > intval($field->maxRow)) {
104 $defaultRow = intval($field->maxRow);
105 }
106
107 if (isset($field->minRow) && $defaultRow < intval($field->minRow)) {
108 $defaultRow = intval($field->minRow);
109 }
110 $repeatedRow = $repeatableWrap;
111 while ($defaultRow > 1) {
112 $repeatedRow .= $repeatableWrap;
113 $defaultRow--;
114 }
115
116 return <<<SECTIONFIELD
117 <div
118 {$fieldHelpers->getCustomAttributes('inp-fld-wrp')}
119 class="{$fieldHelpers->getAtomicCls('inp-fld-wrp')} {$fieldHelpers->getCustomClasses('inp-fld-wrp')}"
120 >
121 <div
122 {$fieldHelpers->getCustomAttributes('rpt-fld-wrp')}
123 class="{$fieldHelpers->getAtomicCls('rpt-fld-wrp')} {$fieldHelpers->getCustomClasses('rpt-fld-wrp')}"
124 >
125 {$repeatedRow}
126 {$addToEndBtnMarkup}
127 <input
128 type="text"
129 class="d-none"
130 title="Rpeater Index Hidden Input"
131 name="{$fieldHelpers->esc_attr($field->fieldName . '-repeat-index')}"
132 value=""
133 />
134 </div>
135 </div>
136 SECTIONFIELD;
137 }
138 }
139