PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.13
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.13
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.13, at app/Modules/Component/BaseComponent.php

210 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 * @return array $default
101 */
102 public function attributes($default)
103 {
104 return $default;
105 }
106
107 /**
108 * Element editor settings and the derived class will
109 * override this method if any customization is needed.
110 *
111 * @param array $dafault
112 * @return array $default
113 */
114 public function settings($default)
115 {
116 return $default;
117 }
118
119 /**
120 * Element editor options and the derived class will
121 * override this method if any customization is needed.
122 *
123 * @param array $dafault
124 * @return array $default
125 */
126 public function options($default)
127 {
128 return $default;
129 }
130
131 /**
132 * Element's form submission validation rules and the derived
133 * class will override this method if needed any customization.
134 *
135 * @return array
136 */
137 public function validationRules()
138 {
139 return [];
140 }
141
142 /**
143 * Element editor placement settings and the derived class
144 * will override this method if any customization is needed.
145 *
146 * @param array $placemenSettings
147 * @return array $placemenSettings
148 */
149 public function placementSettings($placemenSettings)
150 {
151 return $placemenSettings;
152 }
153
154 /**
155 * The customization for the component and derived class can
156 * override this method if any customization is needed.
157 *
158 * @param array $customizationSettings
159 * @return array $customizationSettings
160 */
161 public function customizationSettings($customizationSettings)
162 {
163 return $customizationSettings;
164 }
165
166 /**
167 * Add the component type in fluentform field types to
168 * be available in FormFieldParser and derived class can
169 * override this method if any customization is needed.
170 *
171 * @param array $types
172 * @return array $types
173 */
174 public function addType($types)
175 {
176 $types[] = $this->name();
177
178 return $types;
179 }
180
181 /**
182 * The keywords to search the element in the editor and
183 * the derived class will override this method if needed.
184 *
185 * @return array
186 */
187 public function searchBy()
188 {
189 return [$this->name(), $this->label()];
190 }
191
192 /**
193 * Transform the element's submitted value saved in database
194 * to show it properly/formatted in entry page if needed and
195 * this method implementation optional so a default method is
196 * implemented here and original value is returned. In any case
197 * if any customization of the value is needed then the derived
198 * class will override it and will format and return the the value.
199 *
200 * @param mixed $value [description]
201 * @param string $field
202 * @param int $formId
203 * @return mixed $value
204 */
205 public function formatEntryValue($value, $field, $formId)
206 {
207 return $value;
208 }
209 }
210