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
← All changes | backend/src/Services/Template/BirthdayCakeOrderFormTemplate.php +118 -87 0.9 → 1.5 View file →
@@ -1,23 +1,18 @@
1 1 <?php
2 2
3 3 namespace IvyForms\Services\Template;
4 4
5 -// phpcs:disable PSR1.Files.SideEffects
6 -if (!defined('ABSPATH')) {
7 - exit; // Exit if accessed directly
8 -}
9 -
10 5 use IvyForms\Services\Translations\BackendStrings;
11 6
12 7 class BirthdayCakeOrderFormTemplate
13 8 {
14 9 /**
15 - * Get the birthday cake order form template
10 + * Get template metadata (without form_data)
16 11 *
17 12 * @return array<string, mixed>
18 13 */
19 - public static function getTemplate(): array
14 + public static function getTemplateMeta(): array
20 15 {
21 16 return [
22 17 'id' => 'birthday_cake_order_form',
23 18 'name' => BackendStrings::getTemplateStrings()['birthday_cake_order_form'],
@@ -24,9 +19,22 @@
24 19 'description' => BackendStrings::getTemplateStrings()['birthday_cake_order_form_desc'],
25 20 'category' => 'order-forms',
26 21 'subcategory' => 'cake-order-forms',
27 22 'is_pro' => false,
28 - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'birthday-cake-order-form.svg',
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 + [
29 37 'form_data' => [
30 38 'name' => BackendStrings::getTemplateStrings()['birthday_cake_order_form'],
31 39 'published' => 1,
32 40 'showTitle' => 1,
@@ -38,9 +46,10 @@
38 46 self::getDeliveryDetailsFields()
39 47 ),
40 48 'settings' => []
41 49 ]
42 - ];
50 + ]
51 + );
43 52 }
44 53
45 54 /**
46 55 * Get customer information fields
@@ -262,43 +271,40 @@
262 271 */
263 272 private static function getDeliveryDetailsFields(): array
264 273 {
265 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
266 289 [
267 - // Delivery Date
268 - [
269 - 'id' => 19,
270 - 'fieldIndex' => 9,
271 - 'type' => 'date',
272 - 'label' => BackendStrings::getTemplateStrings()['delivery_date'],
273 - 'placeholder' => BackendStrings::getTemplateStrings()['select_delivery_date'],
274 - 'required' => true,
275 - 'parentId' => null,
276 - 'defaultValue' => '',
277 - 'position' => 9,
278 - 'dateFieldType' => 'picker',
279 - 'dateFormat' => 'MM/DD/YYYY',
280 - ],
281 - // Delivery Address Field - Parent
282 - [
283 - 'id' => 20,
284 - 'fieldIndex' => 10,
285 - 'type' => 'address',
286 - 'label' => BackendStrings::getTemplateStrings()['delivery_address'],
287 - 'parentId' => null,
288 - 'defaultValue' => '',
289 - 'placeholder' => '',
290 - 'readonly' => false,
291 - 'position' => 10,
292 - 'required' => false,
293 - ],
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',
294 301 ],
295 - self::getDeliveryAddressFields()
296 - );
302 + ];
297 303 }
298 304
299 305 /**
300 - * Get delivery address child fields
306 + * Delivery address fields
301 307 *
302 308 * @return array<int, array<string, mixed>>
303 309 */
304 310 private static function getDeliveryAddressFields(): array
@@ -303,8 +309,21 @@
303 309 */
304 310 private static function getDeliveryAddressFields(): array
305 311 {
306 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 + ],
307 326 // Address Line 1 - Child of Address Field
308 327 [
309 328 'id' => 22,
310 329 'type' => 'text',
@@ -317,16 +336,18 @@
317 336 'position' => 1,
318 337 'hideLabel' => false,
319 338 'description' => '',
320 339 'addressType' => 'streetAddress',
321 - 'settings' => json_encode([
322 - 'type' => 'streetAddress',
323 - 'hideLabel' => false,
324 - 'description' => '',
325 - 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
326 - 'requiredMessage' => '',
327 - 'visible' => true
328 - ]),
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 + ),
329 350 ],
330 351 // Address Line 2 - Child of Address Field
331 352 [
332 353 'id' => 24,
@@ -340,16 +361,18 @@
340 361 'position' => 2,
341 362 'hideLabel' => false,
342 363 'description' => '',
343 364 'addressType' => 'addressLine2',
344 - 'settings' => json_encode([
345 - 'type' => 'addressLine2',
346 - 'hideLabel' => false,
347 - 'description' => '',
348 - 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
349 - 'requiredMessage' => '',
350 - 'visible' => true
351 - ]),
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 + ),
352 375 ],
353 376 // City - Child of Address Field
354 377 [
355 378 'id' => 26,
@@ -363,16 +386,18 @@
363 386 'position' => 3,
364 387 'hideLabel' => false,
365 388 'description' => '',
366 389 'addressType' => 'city',
367 - 'settings' => json_encode([
368 - 'type' => 'city',
369 - 'hideLabel' => false,
370 - 'description' => '',
371 - 'placeholder' => BackendStrings::getTemplateStrings()['city'],
372 - 'requiredMessage' => '',
373 - 'visible' => true
374 - ]),
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 + ),
375 400 ],
376 401 // State/Province - Child of Address Field
377 402 [
378 403 'id' => 28,
@@ -386,16 +411,18 @@
386 411 'position' => 4,
387 412 'hideLabel' => false,
388 413 'description' => '',
389 414 'addressType' => 'state',
390 - 'settings' => json_encode([
391 - 'type' => 'state',
392 - 'hideLabel' => false,
393 - 'description' => '',
394 - 'placeholder' => BackendStrings::getTemplateStrings()['state'],
395 - 'requiredMessage' => '',
396 - 'visible' => true
397 - ]),
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 + ),
398 425 ],
399 426 // Zip/Postal Code - Child of Address Field
400 427 [
401 428 'id' => 30,
@@ -409,16 +436,18 @@
409 436 'position' => 5,
410 437 'hideLabel' => false,
411 438 'description' => '',
412 439 'addressType' => 'zip',
413 - 'settings' => json_encode([
414 - 'type' => 'zip',
415 - 'hideLabel' => false,
416 - 'description' => '',
417 - 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
418 - 'requiredMessage' => '',
419 - 'visible' => true
420 - ]),
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 + ),
421 450 ],
422 451 // Country - Child of Address Field
423 452 [
424 453 'id' => 32,
@@ -432,16 +461,18 @@
432 461 'position' => 6,
433 462 'hideLabel' => false,
434 463 'description' => '',
435 464 'addressType' => 'country',
436 - 'settings' => json_encode([
437 - 'type' => 'country',
438 - 'hideLabel' => false,
439 - 'description' => '',
440 - 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
441 - 'requiredMessage' => '',
442 - 'visible' => true
443 - ]),
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 + ),
444 475 ],
445 476 ];
446 477 }
447 478 }