PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
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 / BirthdayCakeOrderFormTemplate.php

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

479 lines 17.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Services\Template;
4
5 use IvyForms\Services\Translations\BackendStrings;
6
7 class BirthdayCakeOrderFormTemplate
8 {
9 /**
10 * Get template metadata (without form_data)
11 *
12 * @return array<string, mixed>
13 */
14 public static function getTemplateMeta(): array
15 {
16 return [
17 'id' => 'birthday_cake_order_form',
18 'name' => BackendStrings::getTemplateStrings()['birthday_cake_order_form'],
19 'description' => BackendStrings::getTemplateStrings()['birthday_cake_order_form_desc'],
20 'category' => 'order-forms',
21 'subcategory' => 'cake-order-forms',
22 'is_pro' => false,
23 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'birthday-cake-order-form.svg'
24 ];
25 }
26
27 /**
28 * Get the full template including form data
29 *
30 * @return array<string, mixed>
31 */
32 public static function getTemplate(): array
33 {
34 return array_merge(
35 self::getTemplateMeta(),
36 [
37 'form_data' => [
38 'name' => BackendStrings::getTemplateStrings()['birthday_cake_order_form'],
39 'published' => 1,
40 'showTitle' => 1,
41 'storeEntries' => 1,
42 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
43 'fields' => array_merge(
44 self::getCustomerInformationFields(),
45 self::getCakeDetailsFields(),
46 self::getDeliveryDetailsFields()
47 ),
48 'settings' => []
49 ]
50 ]
51 );
52 }
53
54 /**
55 * Get customer information fields
56 *
57 * @return array<int, array<string, mixed>>
58 */
59 private static function getCustomerInformationFields(): array
60 {
61 return [
62 // Name Field - Parent
63 [
64 'id' => 1,
65 'fieldIndex' => 1,
66 'type' => 'name',
67 'label' => BackendStrings::getTemplateStrings()['full_name'],
68 'parentId' => null,
69 'defaultValue' => '',
70 'placeholder' => '',
71 'required' => true,
72 'readonly' => false,
73 'position' => 1,
74 ],
75 // First Name - Child of Name Field
76 [
77 'id' => 2,
78 'type' => 'text',
79 'label' => BackendStrings::getNewFormStrings()['first_name'],
80 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
81 'required' => true,
82 'parentId' => 1,
83 'fieldIndex' => 1,
84 'defaultValue' => '',
85 'position' => 1,
86 'optionHide' => false,
87 'description' => '',
88 'settings' => json_encode(['nameFieldType' => 'nameField1']),
89 ],
90 // Last Name - Child of Name Field
91 [
92 'id' => 3,
93 'type' => 'text',
94 'label' => BackendStrings::getNewFormStrings()['last_name'],
95 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
96 'required' => true,
97 'parentId' => 1,
98 'fieldIndex' => 1,
99 'defaultValue' => '',
100 'position' => 2,
101 'optionHide' => false,
102 'description' => '',
103 'settings' => json_encode(['nameFieldType' => 'nameField2']),
104 ],
105 // Email Address
106 [
107 'id' => 4,
108 'fieldIndex' => 2,
109 'type' => 'email',
110 'label' => BackendStrings::getTemplateStrings()['email_address'],
111 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_email'],
112 'required' => true,
113 'parentId' => null,
114 'defaultValue' => '',
115 'position' => 2,
116 ],
117 // Phone Number
118 [
119 'id' => 5,
120 'fieldIndex' => 3,
121 'type' => 'phone',
122 'label' => BackendStrings::getTemplateStrings()['phone_number'],
123 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_phone_number'],
124 'required' => true,
125 'parentId' => null,
126 'defaultValue' => '',
127 'position' => 3,
128 'phoneAutoDetect' => true,
129 ],
130 ];
131 }
132
133 /**
134 * Get cake details fields
135 *
136 * @return array<int, array<string, mixed>>
137 */
138 private static function getCakeDetailsFields(): array
139 {
140 return [
141 // Cake Flavor
142 [
143 'id' => 11,
144 'fieldIndex' => 4,
145 'type' => 'select',
146 'label' => BackendStrings::getTemplateStrings()['cake_flavor'],
147 'placeholder' => BackendStrings::getTemplateStrings()['select_cake_flavor'],
148 'required' => true,
149 'parentId' => null,
150 'defaultValue' => '',
151 'position' => 4,
152 'fieldOptions' => [
153 [
154 'id' => 6,
155 'label' => BackendStrings::getTemplateStrings()['chocolate'],
156 'value' => 'chocolate',
157 'isDefault' => false,
158 'position' => 1
159 ],
160 [
161 'id' => 7,
162 'label' => BackendStrings::getTemplateStrings()['vanilla'],
163 'value' => 'vanilla',
164 'isDefault' => false,
165 'position' => 2
166 ],
167 [
168 'id' => 8,
169 'label' => BackendStrings::getTemplateStrings()['red_velvet'],
170 'value' => 'red_velvet',
171 'isDefault' => false,
172 'position' => 3
173 ],
174 [
175 'id' => 9,
176 'label' => BackendStrings::getTemplateStrings()['lemon'],
177 'value' => 'lemon',
178 'isDefault' => false,
179 'position' => 4
180 ],
181 [
182 'id' => 10,
183 'label' => BackendStrings::getTemplateStrings()['custom'],
184 'value' => 'custom',
185 'isDefault' => false,
186 'position' => 5
187 ],
188 ]
189 ],
190 // Cake Size
191 [
192 'id' => 15,
193 'fieldIndex' => 5,
194 'type' => 'select',
195 'label' => BackendStrings::getTemplateStrings()['cake_size'],
196 'placeholder' => BackendStrings::getTemplateStrings()['select_cake_size'],
197 'required' => true,
198 'parentId' => null,
199 'defaultValue' => '',
200 'position' => 5,
201 'fieldOptions' => [
202 [
203 'id' => 12,
204 'label' => BackendStrings::getTemplateStrings()['small_6_inch'],
205 'value' => 'small_6',
206 'isDefault' => false,
207 'position' => 1
208 ],
209 [
210 'id' => 13,
211 'label' => BackendStrings::getTemplateStrings()['medium_8_inch'],
212 'value' => 'medium_8',
213 'isDefault' => false,
214 'position' => 2
215 ],
216 [
217 'id' => 14,
218 'label' => BackendStrings::getTemplateStrings()['large_10_inch'],
219 'value' => 'large_10',
220 'isDefault' => false,
221 'position' => 3
222 ],
223 ]
224 ],
225 // Number of Guests
226 [
227 'id' => 16,
228 'fieldIndex' => 6,
229 'type' => 'number',
230 'label' => BackendStrings::getTemplateStrings()['number_of_guests'],
231 'placeholder' => BackendStrings::getTemplateStrings()['eg_20'],
232 'required' => true,
233 'parentId' => null,
234 'defaultValue' => '',
235 'position' => 6,
236 'minValue' => 1,
237 'maxValue' => 500,
238 ],
239 // Birthday Message on Cake
240 [
241 'id' => 17,
242 'fieldIndex' => 7,
243 'type' => 'text',
244 'label' => BackendStrings::getTemplateStrings()['birthday_message_on_cake'],
245 'placeholder' => BackendStrings::getTemplateStrings()['happy_10th_birthday'],
246 'required' => true,
247 'parentId' => null,
248 'defaultValue' => '',
249 'position' => 7,
250 ],
251 // Special Requests / Design Ideas
252 [
253 'id' => 18,
254 'fieldIndex' => 8,
255 'type' => 'textarea',
256 'label' => BackendStrings::getTemplateStrings()['special_requests_design_ideas'],
257 'placeholder' => BackendStrings::getTemplateStrings()['describe_cake_design_decorations'],
258 'required' => false,
259 'parentId' => null,
260 'defaultValue' => '',
261 'position' => 8,
262 'rows' => 4,
263 ],
264 ];
265 }
266
267 /**
268 * Get delivery details fields
269 *
270 * @return array<int, array<string, mixed>>
271 */
272 private static function getDeliveryDetailsFields(): array
273 {
274 return array_merge(
275 self::getDeliveryDateFields(),
276 self::getDeliveryAddressFields()
277 );
278 }
279
280 /**
281 * Delivery date fields
282 *
283 * @return array<int, array<string, mixed>>
284 */
285 private static function getDeliveryDateFields(): array
286 {
287 return [
288 // Delivery Date
289 [
290 'id' => 19,
291 'fieldIndex' => 9,
292 'type' => 'date',
293 'label' => BackendStrings::getTemplateStrings()['delivery_date'],
294 'placeholder' => BackendStrings::getTemplateStrings()['select_delivery_date'],
295 'required' => true,
296 'parentId' => null,
297 'defaultValue' => '',
298 'position' => 9,
299 'dateFieldType' => 'picker',
300 'dateFormat' => 'MM/DD/YYYY',
301 ],
302 ];
303 }
304
305 /**
306 * Delivery address fields
307 *
308 * @return array<int, array<string, mixed>>
309 */
310 private static function getDeliveryAddressFields(): array
311 {
312 return [
313 // Delivery Address Field - Parent
314 [
315 'id' => 20,
316 'fieldIndex' => 10,
317 'type' => 'address',
318 'label' => BackendStrings::getTemplateStrings()['delivery_address'],
319 'parentId' => null,
320 'defaultValue' => '',
321 'placeholder' => '',
322 'readonly' => false,
323 'position' => 10,
324 'required' => false,
325 ],
326 // Address Line 1 - Child of Address Field
327 [
328 'id' => 22,
329 'type' => 'text',
330 'label' => BackendStrings::getTemplateStrings()['address_line_1'],
331 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
332 'required' => true,
333 'parentId' => 10,
334 'fieldIndex' => 10,
335 'defaultValue' => '',
336 'position' => 1,
337 'hideLabel' => false,
338 'description' => '',
339 'addressType' => 'streetAddress',
340 'settings' => json_encode(
341 [
342 'type' => 'streetAddress',
343 'hideLabel' => false,
344 'description' => '',
345 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
346 'requiredMessage' => '',
347 'visible' => true
348 ]
349 ),
350 ],
351 // Address Line 2 - Child of Address Field
352 [
353 'id' => 24,
354 'type' => 'text',
355 'label' => BackendStrings::getTemplateStrings()['address_line_2'],
356 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
357 'required' => false,
358 'parentId' => 10,
359 'fieldIndex' => 10,
360 'defaultValue' => '',
361 'position' => 2,
362 'hideLabel' => false,
363 'description' => '',
364 'addressType' => 'addressLine2',
365 'settings' => json_encode(
366 [
367 'type' => 'addressLine2',
368 'hideLabel' => false,
369 'description' => '',
370 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
371 'requiredMessage' => '',
372 'visible' => true
373 ]
374 ),
375 ],
376 // City - Child of Address Field
377 [
378 'id' => 26,
379 'type' => 'text',
380 'label' => BackendStrings::getTemplateStrings()['city'],
381 'placeholder' => BackendStrings::getTemplateStrings()['city'],
382 'required' => true,
383 'parentId' => 10,
384 'fieldIndex' => 10,
385 'defaultValue' => '',
386 'position' => 3,
387 'hideLabel' => false,
388 'description' => '',
389 'addressType' => 'city',
390 'settings' => json_encode(
391 [
392 'type' => 'city',
393 'hideLabel' => false,
394 'description' => '',
395 'placeholder' => BackendStrings::getTemplateStrings()['city'],
396 'requiredMessage' => '',
397 'visible' => true
398 ]
399 ),
400 ],
401 // State/Province - Child of Address Field
402 [
403 'id' => 28,
404 'type' => 'text',
405 'label' => BackendStrings::getTemplateStrings()['state_province'],
406 'placeholder' => BackendStrings::getTemplateStrings()['state'],
407 'required' => true,
408 'parentId' => 10,
409 'fieldIndex' => 10,
410 'defaultValue' => '',
411 'position' => 4,
412 'hideLabel' => false,
413 'description' => '',
414 'addressType' => 'state',
415 'settings' => json_encode(
416 [
417 'type' => 'state',
418 'hideLabel' => false,
419 'description' => '',
420 'placeholder' => BackendStrings::getTemplateStrings()['state'],
421 'requiredMessage' => '',
422 'visible' => true
423 ]
424 ),
425 ],
426 // Zip/Postal Code - Child of Address Field
427 [
428 'id' => 30,
429 'type' => 'text',
430 'label' => BackendStrings::getTemplateStrings()['zip_postal_code'],
431 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
432 'required' => true,
433 'parentId' => 10,
434 'fieldIndex' => 10,
435 'defaultValue' => '',
436 'position' => 5,
437 'hideLabel' => false,
438 'description' => '',
439 'addressType' => 'zip',
440 'settings' => json_encode(
441 [
442 'type' => 'zip',
443 'hideLabel' => false,
444 'description' => '',
445 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
446 'requiredMessage' => '',
447 'visible' => true
448 ]
449 ),
450 ],
451 // Country - Child of Address Field
452 [
453 'id' => 32,
454 'type' => 'text',
455 'label' => BackendStrings::getTemplateStrings()['country'],
456 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
457 'required' => true,
458 'parentId' => 10,
459 'fieldIndex' => 10,
460 'defaultValue' => '',
461 'position' => 6,
462 'hideLabel' => false,
463 'description' => '',
464 'addressType' => 'country',
465 'settings' => json_encode(
466 [
467 'type' => 'country',
468 'hideLabel' => false,
469 'description' => '',
470 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
471 'requiredMessage' => '',
472 'visible' => true
473 ]
474 ),
475 ],
476 ];
477 }
478 }
479