PluginProbe
The Innovative Form Builder – IvyForms / 1.1
The Innovative Form Builder – IvyForms v1.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Template / ProductFeedbackFormTemplate.php

ProductFeedbackFormTemplate.php in The Innovative Form Builder – IvyForms 1.1, at backend/src/Services/Template/ProductFeedbackFormTemplate.php

307 lines 10.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace IvyForms\Services\Template;
6
7 use IvyForms\Services\Translations\BackendStrings;
8
9 /**
10 * Product Feedback Form Template
11 *
12 * Collect feedback about a specific product to improve quality, features, and usability.
13 */
14 class ProductFeedbackFormTemplate
15 {
16 /**
17 * Get template metadata (without form_data)
18 *
19 * @return array<string, mixed>
20 */
21 public static function getTemplateMeta(): array
22 {
23 return [
24 'id' => 'product_feedback_form',
25 'name' => BackendStrings::getTemplateStrings()['product_feedback_form'],
26 'description' => BackendStrings::getTemplateStrings()['product_feedback_form_desc'],
27 'category' => 'feedback-forms',
28 'subcategory' => 'customer-feedback-forms',
29 'is_pro' => false,
30 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'product-feedback-form.svg',
31 ];
32 }
33
34 /**
35 * Get the full template including form data
36 *
37 * @return array<string, mixed>
38 */
39 public static function getTemplate(): array
40 {
41 return array_merge(
42 self::getTemplateMeta(),
43 [
44 'form_data' => [
45 'name' => BackendStrings::getTemplateStrings()['product_feedback_form'],
46 'published' => 1,
47 'showTitle' => 1,
48 'storeEntries' => 1,
49 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
50 'fields' => array_merge(
51 self::getProductNameField(),
52 self::getIssuesExperiencedCheckboxField(),
53 self::getProductQualityRatingField(),
54 self::getValueForMoneyRatingField(),
55 self::getWhatDidYouLikeMostTextareaField(),
56 self::getWhatCanBeImprovedTextareaField()
57 ),
58 'settings' => []
59 ]
60 ]
61 );
62 }
63
64 /**
65 * Product name dropdown (required)
66 *
67 * @return array<int, array<string, mixed>>
68 */
69 private static function getProductNameField(): array
70 {
71 return [[
72 'id' => 5,
73 'fieldIndex' => 1,
74 'type' => 'select',
75 'label' => BackendStrings::getTemplateStrings()['product_name'],
76 'required' => true,
77 'parentId' => null,
78 'defaultValue' => '',
79 'placeholder' => BackendStrings::getTemplateStrings()['product_name_placeholder'],
80 'position' => 1,
81 'fieldOptions' => [
82 [
83 'id' => 1,
84 'label' => BackendStrings::getTemplateStrings()['product_a'],
85 'value' => 'product_a',
86 'isDefault' => false,
87 'position' => 1,
88 ],
89 [
90 'id' => 2,
91 'label' => BackendStrings::getTemplateStrings()['product_b'],
92 'value' => 'product_b',
93 'isDefault' => false,
94 'position' => 2,
95 ],
96 [
97 'id' => 3,
98 'label' => BackendStrings::getTemplateStrings()['product_c'],
99 'value' => 'product_c',
100 'isDefault' => false,
101 'position' => 3,
102 ],
103 [
104 'id' => 4,
105 'label' => BackendStrings::getTemplateStrings()['other'],
106 'value' => 'other',
107 'isDefault' => false,
108 'position' => 4,
109 ],
110 ]
111 ]];
112 }
113
114 /**
115 * Issues experienced checkbox (optional)
116 *
117 * @return array<int, array<string, mixed>>
118 */
119 private static function getIssuesExperiencedCheckboxField(): array
120 {
121 return [[
122 'id' => 11,
123 'fieldIndex' => 2,
124 'type' => 'checkbox',
125 'label' => BackendStrings::getTemplateStrings()['issues_experienced'],
126 'required' => false,
127 'parentId' => null,
128 'defaultValue' => '',
129 'placeholder' => '',
130 'position' => 2,
131 'fieldOptions' => [
132 [
133 'id' => 6,
134 'label' => BackendStrings::getNewFormStrings()['difficult_to_use'],
135 'value' => 'difficult_to_use',
136 'isDefault' => false,
137 'position' => 1,
138 ],
139 [
140 'id' => 7,
141 'label' => BackendStrings::getTemplateStrings()['missing_features'],
142 'value' => 'missing_features',
143 'isDefault' => false,
144 'position' => 2,
145 ],
146 [
147 'id' => 8,
148 'label' => BackendStrings::getTemplateStrings()['performance_issues'],
149 'value' => 'performance_issues',
150 'isDefault' => false,
151 'position' => 3,
152 ],
153 [
154 'id' => 9,
155 'label' => BackendStrings::getTemplateStrings()['quality_concerns'],
156 'value' => 'quality_concerns',
157 'isDefault' => false,
158 'position' => 4,
159 ],
160 [
161 'id' => 10,
162 'label' => BackendStrings::getTemplateStrings()['no_issues'],
163 'value' => 'no_issues',
164 'isDefault' => false,
165 'position' => 5,
166 ],
167 ]
168 ]];
169 }
170
171 /**
172 * Product quality rating (required)
173 *
174 * @return array<int, array<string, mixed>>
175 */
176 private static function getProductQualityRatingField(): array
177 {
178 return [[
179 'id' => 12,
180 'fieldIndex' => 3,
181 'type' => 'rating',
182 'label' => BackendStrings::getTemplateStrings()['product_quality'],
183 'required' => true,
184 'defaultValue' => '',
185 'placeholder' => '',
186 'position' => 3,
187 'labelPosition' => 'default',
188 'ratingIcon' => 'star',
189 'fieldOptions' => self::getStandardRatingOptions(5),
190 'showValues' => false,
191 'showRatingText' => true,
192 ]];
193 }
194
195 /**
196 * Value for money rating (required)
197 *
198 * @return array<int, array<string, mixed>>
199 */
200 private static function getValueForMoneyRatingField(): array
201 {
202 return [[
203 'id' => 13,
204 'fieldIndex' => 4,
205 'type' => 'rating',
206 'label' => BackendStrings::getTemplateStrings()['value_for_money'],
207 'required' => true,
208 'defaultValue' => '',
209 'placeholder' => '',
210 'position' => 4,
211 'labelPosition' => 'default',
212 'ratingIcon' => 'star',
213 'fieldOptions' => self::getStandardRatingOptions(10),
214 'showValues' => false,
215 'showRatingText' => true,
216 ]];
217 }
218
219 /**
220 * What did you like the most textarea (optional)
221 *
222 * @return array<int, array<string, mixed>>
223 */
224 private static function getWhatDidYouLikeMostTextareaField(): array
225 {
226 return [[
227 'id' => 14,
228 'fieldIndex' => 5,
229 'type' => 'textarea',
230 'label' => BackendStrings::getTemplateStrings()['what_did_you_like_most'],
231 'placeholder' => BackendStrings::getTemplateStrings()['what_did_you_like_most_placeholder'],
232 'required' => false,
233 'parentId' => null,
234 'defaultValue' => '',
235 'position' => 5,
236 'labelPosition' => 'default',
237 ]];
238 }
239
240 /**
241 * What can be improved textarea (optional)
242 *
243 * @return array<int, array<string, mixed>>
244 */
245 private static function getWhatCanBeImprovedTextareaField(): array
246 {
247 return [[
248 'id' => 15,
249 'fieldIndex' => 6,
250 'type' => 'textarea',
251 'label' => BackendStrings::getTemplateStrings()['what_can_be_improved'],
252 'placeholder' => BackendStrings::getTemplateStrings()['what_can_be_improved_placeholder'],
253 'required' => false,
254 'parentId' => null,
255 'defaultValue' => '',
256 'position' => 6,
257 'labelPosition' => 'default',
258 ]];
259 }
260
261 /**
262 * Standard rating options (1-5)
263 *
264 * @return array<int, array<string, mixed>>
265 */
266 private static function getStandardRatingOptions(int $startId): array
267 {
268 return [
269 [
270 'id' => $startId,
271 'label' => BackendStrings::getNewFormStrings()['good'],
272 'value' => '1',
273 'isDefault' => false,
274 'position' => 1
275 ],
276 [
277 'id' => $startId + 1,
278 'label' => BackendStrings::getNewFormStrings()['nice'],
279 'value' => '2',
280 'isDefault' => false,
281 'position' => 2
282 ],
283 [
284 'id' => $startId + 2,
285 'label' => BackendStrings::getNewFormStrings()['very_good'],
286 'value' => '3',
287 'isDefault' => false,
288 'position' => 3
289 ],
290 [
291 'id' => $startId + 3,
292 'label' => BackendStrings::getNewFormStrings()['awesome'],
293 'value' => '4',
294 'isDefault' => false,
295 'position' => 4
296 ],
297 [
298 'id' => $startId + 4,
299 'label' => BackendStrings::getNewFormStrings()['amazing'],
300 'value' => '5',
301 'isDefault' => false,
302 'position' => 5
303 ],
304 ];
305 }
306 }
307