PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.1.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.1.1
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 / Conversational / Fields / DecisionBoxField.php

DecisionBoxField.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 3.1.1, at includes/Frontend/Form/View/Conversational/Fields/DecisionBoxField.php

115 lines 4.4 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\Conversational\Fields;
4
5 use BitCode\BitForm\Core\Util\FrontendHelpers;
6
7 class DecisionBoxField
8 {
9 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
10 {
11 $inputWrapper = new ConversationalInputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
12 $input = self::field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
13 return $inputWrapper->wrapper($input, true);
14 }
15
16 private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null)
17 {
18 $fieldHelpers = new ConversationalFieldHelpers($formID, $field, $rowID, $form_atomic_Cls_map);
19
20 $suggestions = '';
21 $req = $fieldHelpers->required();
22 $disabled = '';
23 $readonly = '';
24 $name = $fieldHelpers->name();
25 $ariaDescribedBy = $fieldHelpers->ariaDescribedBy();
26 $ariaRequired = $fieldHelpers->ariaRequired();
27 $labelId = $fieldHelpers->getLabelId();
28 $value = '';
29 $bfFrontendFormIds = FrontendHelpers::$bfFrontendFormIds;
30 $contentCount = count($bfFrontendFormIds);
31 if ($fieldHelpers->property_exists_nested($field, 'msg->checked')) {
32 $value = "value='{$field->msg->checked}'";
33 }
34 $checked = '';
35
36 if ($fieldHelpers->property_exists_nested($field, 'valid->disabled', true)) {
37 $disabled = 'disabled';
38 }
39
40 if ($fieldHelpers->property_exists_nested($field, 'valid->checked', true)) {
41 $checked = 'checked';
42 }
43
44 if ($fieldHelpers->property_exists_nested($field, 'valid->readonly', true)) {
45 $readonly = 'readonly';
46 }
47
48 $lbl = '';
49 if (isset($field->lbl) && !empty($field->lbl)) {
50 $lbl = $field->lbl;
51 } elseif ($fieldHelpers->property_exists_nested($field, 'info->lbl') && !empty($field->info->lbl)) {
52 $lbl = $field->info->lbl;
53 }
54
55 return '
56 <div
57 ' . $fieldHelpers->getCustomAttributes('cc') . '
58 class="' . $fieldHelpers->getConversationalCls('cc') . ' ' . $fieldHelpers->getCustomClasses('cc') . '"
59 role="group"
60 aria-labelledby="' . $labelId . '"
61 ' . $ariaDescribedBy . '
62 >
63 <svg class="' . $fieldHelpers->getConversationalCls('cks') . '" aria-hidden="true">
64 <symbol id="' . $rowID . '-ck-svg" viewBox="0 0 12 10">
65 <polyline
66 class="' . $fieldHelpers->getConversationalCls('ck-svgline') . '"
67 points="1.5 6 4.5 9 10.5 1"
68 ></polyline>
69 </symbol>
70 </svg>
71
72 <div
73 ' . $fieldHelpers->getCustomAttributes('cw') . '
74 class="' . $fieldHelpers->getConversationalCls('cw') . ' ' . $fieldHelpers->getCustomClasses('cw') . '"
75 >
76 <input
77 id="' . $rowID . '-' . $contentCount . '-decision"
78 type="checkbox"
79 class="' . $fieldHelpers->getConversationalCls('ci') . '"
80 ' . $disabled . '
81 ' . $readonly . '
82 ' . $req . '
83 ' . $ariaRequired . '
84 ' . $name . '
85 ' . $checked . '
86 ' . $value . '
87 />
88 <!-- aria-describedby is on the parent group wrapper to associate helper/error text with the entire field -->
89 <label
90 ' . $fieldHelpers->getCustomAttributes('cl') . '
91 data-cl
92 for="' . $rowID . '-' . $contentCount . '-decision"
93 class="' . $fieldHelpers->getConversationalCls('cl') . '"
94 >
95 <span
96 ' . $fieldHelpers->getCustomAttributes('bx') . '
97 data-bx
98 class="' . $fieldHelpers->getConversationalCls('bx') . ' ' . $fieldHelpers->getConversationalCls('bx') . '"
99 >
100 <svg width="12" height="10" viewBox="0 0 12 10" class="' . $fieldHelpers->getConversationalCls('svgwrp') . '">
101 <use data-ck-icn href="#' . $rowID . '-ck-svg" class="' . $fieldHelpers->getConversationalCls('ck-icn') . '" />
102 </svg>
103 </span>
104 <span
105 ' . $fieldHelpers->getCustomAttributes('ct') . '
106 class="' . $fieldHelpers->getConversationalCls('ct') . ' ' . $fieldHelpers->getCustomClasses('ct') . '"
107 >
108 ' . $fieldHelpers->kses_post($fieldHelpers->renderHTMR($lbl)) . '
109 </span>
110 </label>
111 </div>
112 </div>';
113 }
114 }
115