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/ContactFormTemplate.php +61 -33 0.8 → 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 ContactFormTemplate
13 8 {
14 9 /**
15 - * Get the contact 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' => 'contact_form',
23 18 'name' => BackendStrings::getTemplateStrings()['contact_form'],
@@ -22,10 +17,24 @@
22 17 'id' => 'contact_form',
23 18 'name' => BackendStrings::getTemplateStrings()['contact_form'],
24 19 'description' => BackendStrings::getTemplateStrings()['contact_form_desc'],
25 20 'category' => 'contact-forms',
21 + 'subcategory' => 'emergency-contact-forms',
26 22 'is_pro' => false,
27 - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'contact-form.svg',
23 + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'contact-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 + [
28 37 'form_data' => [
29 38 'name' => BackendStrings::getTemplateStrings()['contact_form'],
30 39 'published' => 1,
31 40 'showTitle' => 1,
@@ -31,39 +40,54 @@
31 40 'showTitle' => 1,
32 41 'storeEntries' => 1,
33 42 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
34 43 'fields' => [
44 + // Name Field - Parent
35 45 [
36 - 'id' => 'first_name',
46 + 'id' => 1,
37 47 'fieldIndex' => 1,
48 + 'type' => 'name',
49 + 'label' => BackendStrings::getTemplateStrings()['full_name'],
50 + 'parentId' => null,
51 + 'defaultValue' => '',
52 + 'placeholder' => '',
53 + 'required' => true,
54 + 'readonly' => false,
55 + 'position' => 1,
56 + ],
57 + // First Name - Child of Name Field
58 + [
59 + 'id' => 2,
38 60 'type' => 'text',
39 61 'label' => BackendStrings::getTemplateStrings()['first_name'],
40 62 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
41 63 'required' => true,
42 - 'validation' => [
43 - 'required' => true,
44 - ],
45 - 'settings' => [
46 - 'css_class' => 'ivyforms-field-first-name'
47 - ]
64 + 'parentId' => 1,
65 + 'fieldIndex' => 1,
66 + 'defaultValue' => '',
67 + 'position' => 1,
68 + 'optionHide' => false,
69 + 'description' => '',
70 + 'settings' => json_encode(['nameFieldType' => 'nameField1']),
48 71 ],
72 + // Last Name - Child of Name Field
49 73 [
50 - 'id' => 'last_name',
51 - 'fieldIndex' => 2,
74 + 'id' => 3,
52 75 'type' => 'text',
53 76 'label' => BackendStrings::getTemplateStrings()['last_name'],
54 77 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
55 78 'required' => true,
56 - 'validation' => [
57 - 'required' => true,
58 - ],
59 - 'settings' => [
60 - 'css_class' => 'ivyforms-field-last-name'
61 - ]
79 + 'parentId' => 1,
80 + 'fieldIndex' => 1,
81 + 'defaultValue' => '',
82 + 'position' => 2,
83 + 'optionHide' => false,
84 + 'description' => '',
85 + 'settings' => json_encode(['nameFieldType' => 'nameField2']),
62 86 ],
63 87 [
64 - 'id' => 'email',
65 - 'fieldIndex' => 3,
88 + 'id' => 4,
89 + 'fieldIndex' => 2,
66 90 'type' => 'email',
67 91 'label' => BackendStrings::getTemplateStrings()['email_address'],
68 92 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_email_address'],
69 93 'required' => true,
@@ -72,13 +96,14 @@
72 96 'email' => true
73 97 ],
74 98 'settings' => [
75 99 'css_class' => 'ivyforms-field-email'
76 - ]
100 + ],
101 + 'position' => 2,
77 102 ],
78 103 [
79 - 'id' => 'subject',
80 - 'fieldIndex' => 4,
104 + 'id' => 5,
105 + 'fieldIndex' => 3,
81 106 'type' => 'text',
82 107 'label' => BackendStrings::getTemplateStrings()['subject'],
83 108 'placeholder' => BackendStrings::getTemplateStrings()['what_is_this_regarding'],
84 109 'required' => false,
@@ -86,13 +111,14 @@
86 111 'required' => false,
87 112 ],
88 113 'settings' => [
89 114 'css_class' => 'ivyforms-field-subject'
90 - ]
115 + ],
116 + 'position' => 3,
91 117 ],
92 118 [
93 - 'id' => 'message',
94 - 'fieldIndex' => 5,
119 + 'id' => 6,
120 + 'fieldIndex' => 4,
95 121 'type' => 'textarea',
96 122 'label' => BackendStrings::getTemplateStrings()['message'],
97 123 'placeholder' => BackendStrings::getTemplateStrings()['please_enter_your_message_here'],
98 124 'required' => false,
@@ -100,12 +126,14 @@
100 126 'required' => false,
101 127 ],
102 128 'settings' => [
103 129 'css_class' => 'ivyforms-field-message'
104 - ]
130 + ],
131 + 'position' => 4,
105 132 ]
106 133 ],
107 134 'settings' => []
108 135 ]
109 - ];
136 + ]
137 + );
110 138 }
111 139 }