PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.21
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.21
6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 3.6.66 All 195 releases
fluentform / app / Modules / Component / BaseComponent.php

BaseComponent.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 4.3.21, at app/Modules/Component/BaseComponent.php

217 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Modules\Component;
4
5 abstract class BaseComponent
6 {
7 use ComponentInitTrait;
8
9 /**
10 * The unique name of the component.
11 *
12 * @return string
13 */
14 abstract public function name();
15
16 /**
17 * The label of the component.
18 *
19 * @return string
20 */
21 abstract public function label();
22
23 /**
24 * The element type of the component from already
25 * available elements (input_text, textarea e.t.c).
26 *
27 * @return string
28 */
29 abstract public function element();
30
31 /**
32 * The template type of the component to display preview in editor dropzone from
33 * already available templates (inputText, selectCountry, addressFields e.t.c).
34 *
35 * @return string
36 */
37 abstract public function template();
38
39 /**
40 * Render the element on frontend form.
41 *
42 * @param array $component Element Config
43 * @param object $form The Form Object
44 *
45 * @return void
46 */
47 abstract public function render($component, $form);
48
49 /**
50 * Form submission callback.
51 *
52 * @param array $formData Submitted form data
53 * @param int $formId Submitted form id
54 * @param array $config Form elements config
55 *
56 * @return array $formData
57 */
58 abstract public function onSubmit($formData, $formId, $config);
59
60 /**
61 * Component position in editor. If null is returned then
62 * the element will be pushed at last but the derived class
63 * will override this method if any customization is needed.
64 *
65 * @return int|null
66 */
67 public function index()
68 {
69 return null;
70 }
71
72 /**
73 * The group, where the component should be added. By default,
74 * the element will be added in "general" group and the derived
75 * class will override this method if any customization is needed.
76 *
77 * @return string general|advanced|container
78 */
79 public function group()
80 {
81 return 'general';
82 }
83
84 /**
85 * The element icon class for the component to display in the button in
86 * the editor element list which is mapped to editor_options.icon_class.
87 *
88 * @return string
89 */
90 public function elementIconClass()
91 {
92 return 'icon-cog';
93 }
94
95 /**
96 * Element editor/form attributes and the derived class will
97 * override this method if any customization is needed.
98 *
99 * @param array $dafault
100 *
101 * @return array $default
102 */
103 public function attributes($default)
104 {
105 return $default;
106 }
107
108 /**
109 * Element editor settings and the derived class will
110 * override this method if any customization is needed.
111 *
112 * @param array $dafault
113 *
114 * @return array $default
115 */
116 public function settings($default)
117 {
118 return $default;
119 }
120
121 /**
122 * Element editor options and the derived class will
123 * override this method if any customization is needed.
124 *
125 * @param array $dafault
126 *
127 * @return array $default
128 */
129 public function options($default)
130 {
131 return $default;
132 }
133
134 /**
135 * Element's form submission validation rules and the derived
136 * class will override this method if needed any customization.
137 *
138 * @return array
139 */
140 public function validationRules()
141 {
142 return [];
143 }
144
145 /**
146 * Element editor placement settings and the derived class
147 * will override this method if any customization is needed.
148 *
149 * @param array $placemenSettings
150 *
151 * @return array $placemenSettings
152 */
153 public function placementSettings($placemenSettings)
154 {
155 return $placemenSettings;
156 }
157
158 /**
159 * The customization for the component and derived class can
160 * override this method if any customization is needed.
161 *
162 * @param array $customizationSettings
163 *
164 * @return array $customizationSettings
165 */
166 public function customizationSettings($customizationSettings)
167 {
168 return $customizationSettings;
169 }
170
171 /**
172 * Add the component type in fluentform field types to
173 * be available in FormFieldParser and derived class can
174 * override this method if any customization is needed.
175 *
176 * @param array $types
177 *
178 * @return array $types
179 */
180 public function addType($types)
181 {
182 $types[] = $this->name();
183
184 return $types;
185 }
186
187 /**
188 * The keywords to search the element in the editor and
189 * the derived class will override this method if needed.
190 *
191 * @return array
192 */
193 public function searchBy()
194 {
195 return [$this->name(), $this->label()];
196 }
197
198 /**
199 * Transform the element's submitted value saved in database
200 * to show it properly/formatted in entry page if needed and
201 * this method implementation optional so a default method is
202 * implemented here and original value is returned. In any case
203 * if any customization of the value is needed then the derived
204 * class will override it and will format and return the the value.
205 *
206 * @param mixed $value [description]
207 * @param string $field
208 * @param int $formId
209 *
210 * @return mixed $value
211 */
212 public function formatEntryValue($value, $field, $formId)
213 {
214 return $value;
215 }
216 }
217