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 +73 -43 0.5 → 1.5 View file →
@@ -1,8 +1,6 @@
1 1 <?php
2 2
3 -declare(strict_types=1);
4 -
5 3 namespace IvyForms\Services\Template;
6 4
7 5 use IvyForms\Services\Translations\BackendStrings;
8 6
@@ -8,63 +6,91 @@
8 6
9 7 class ContactFormTemplate
10 8 {
11 9 /**
12 - * Get the contact form template
10 + * Get template metadata (without form_data)
13 11 *
14 12 * @return array<string, mixed>
15 13 */
16 - public static function getTemplate(): array
14 + public static function getTemplateMeta(): array
17 15 {
18 16 return [
19 17 'id' => 'contact_form',
20 18 'name' => BackendStrings::getTemplateStrings()['contact_form'],
21 19 'description' => BackendStrings::getTemplateStrings()['contact_form_desc'],
22 - 'category' => 'basic',
20 + 'category' => 'contact-forms',
21 + 'subcategory' => 'emergency-contact-forms',
23 22 'is_pro' => false,
24 - '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 + [
25 37 'form_data' => [
26 - 'name' => 'Contact Form',
27 - 'description' => 'Get in touch with us using this contact form',
38 + 'name' => BackendStrings::getTemplateStrings()['contact_form'],
28 39 'published' => 1,
29 40 'showTitle' => 1,
30 41 'storeEntries' => 1,
31 42 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
32 43 'fields' => [
44 + // Name Field - Parent
33 45 [
34 - 'id' => 'first_name',
46 + 'id' => 1,
35 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,
36 60 'type' => 'text',
37 - 'label' => 'First Name',
38 - 'placeholder' => 'Enter your first name',
61 + 'label' => BackendStrings::getTemplateStrings()['first_name'],
62 + 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
39 63 'required' => true,
40 - 'validation' => [
41 - 'required' => true,
42 - ],
43 - 'settings' => [
44 - 'css_class' => 'ivyforms-field-first-name'
45 - ]
64 + 'parentId' => 1,
65 + 'fieldIndex' => 1,
66 + 'defaultValue' => '',
67 + 'position' => 1,
68 + 'optionHide' => false,
69 + 'description' => '',
70 + 'settings' => json_encode(['nameFieldType' => 'nameField1']),
46 71 ],
72 + // Last Name - Child of Name Field
47 73 [
48 - 'id' => 'last_name',
49 - 'fieldIndex' => 2,
74 + 'id' => 3,
50 75 'type' => 'text',
51 - 'label' => 'Last Name',
52 - 'placeholder' => 'Enter your last name',
76 + 'label' => BackendStrings::getTemplateStrings()['last_name'],
77 + 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
53 78 'required' => true,
54 - 'validation' => [
55 - 'required' => true,
56 - ],
57 - 'settings' => [
58 - 'css_class' => 'ivyforms-field-last-name'
59 - ]
79 + 'parentId' => 1,
80 + 'fieldIndex' => 1,
81 + 'defaultValue' => '',
82 + 'position' => 2,
83 + 'optionHide' => false,
84 + 'description' => '',
85 + 'settings' => json_encode(['nameFieldType' => 'nameField2']),
60 86 ],
61 87 [
62 - 'id' => 'email',
63 - 'fieldIndex' => 3,
88 + 'id' => 4,
89 + 'fieldIndex' => 2,
64 90 'type' => 'email',
65 - 'label' => 'Email Address',
66 - 'placeholder' => 'Enter your email address',
91 + 'label' => BackendStrings::getTemplateStrings()['email_address'],
92 + 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_email_address'],
67 93 'required' => true,
68 94 'validation' => [
69 95 'required' => true,
70 96 'email' => true
@@ -70,16 +96,17 @@
70 96 'email' => true
71 97 ],
72 98 'settings' => [
73 99 'css_class' => 'ivyforms-field-email'
74 - ]
100 + ],
101 + 'position' => 2,
75 102 ],
76 103 [
77 - 'id' => 'subject',
78 - 'fieldIndex' => 4,
104 + 'id' => 5,
105 + 'fieldIndex' => 3,
79 106 'type' => 'text',
80 - 'label' => 'Subject',
81 - 'placeholder' => 'What is this regarding?',
107 + 'label' => BackendStrings::getTemplateStrings()['subject'],
108 + 'placeholder' => BackendStrings::getTemplateStrings()['what_is_this_regarding'],
82 109 'required' => false,
83 110 'validation' => [
84 111 'required' => false,
85 112 ],
@@ -84,16 +111,17 @@
84 111 'required' => false,
85 112 ],
86 113 'settings' => [
87 114 'css_class' => 'ivyforms-field-subject'
88 - ]
115 + ],
116 + 'position' => 3,
89 117 ],
90 118 [
91 - 'id' => 'message',
92 - 'fieldIndex' => 5,
119 + 'id' => 6,
120 + 'fieldIndex' => 4,
93 121 'type' => 'textarea',
94 - 'label' => 'Message',
95 - 'placeholder' => 'Please enter your message here...',
122 + 'label' => BackendStrings::getTemplateStrings()['message'],
123 + 'placeholder' => BackendStrings::getTemplateStrings()['please_enter_your_message_here'],
96 124 'required' => false,
97 125 'validation' => [
98 126 'required' => false,
99 127 ],
@@ -98,12 +126,14 @@
98 126 'required' => false,
99 127 ],
100 128 'settings' => [
101 129 'css_class' => 'ivyforms-field-message'
102 - ]
130 + ],
131 + 'position' => 4,
103 132 ]
104 133 ],
105 134 'settings' => []
106 135 ]
107 - ];
136 + ]
137 + );
108 138 }
109 139 }