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 +75 -39 0.3 → 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,59 +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,
42 + 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
31 43 'fields' => [
44 + // Name Field - Parent
32 45 [
33 - 'id' => 'first_name',
46 + 'id' => 1,
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,
34 60 'type' => 'text',
35 - 'label' => 'First Name',
36 - 'placeholder' => 'Enter your first name',
61 + 'label' => BackendStrings::getTemplateStrings()['first_name'],
62 + 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
37 63 'required' => true,
38 - 'validation' => [
39 - 'required' => true,
40 - ],
41 - 'settings' => [
42 - 'css_class' => 'ivyforms-field-first-name'
43 - ]
64 + 'parentId' => 1,
65 + 'fieldIndex' => 1,
66 + 'defaultValue' => '',
67 + 'position' => 1,
68 + 'optionHide' => false,
69 + 'description' => '',
70 + 'settings' => json_encode(['nameFieldType' => 'nameField1']),
44 71 ],
72 + // Last Name - Child of Name Field
45 73 [
46 - 'id' => 'last_name',
74 + 'id' => 3,
47 75 'type' => 'text',
48 - 'label' => 'Last Name',
49 - 'placeholder' => 'Enter your last name',
76 + 'label' => BackendStrings::getTemplateStrings()['last_name'],
77 + 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
50 78 'required' => true,
51 - 'validation' => [
52 - 'required' => true,
53 - ],
54 - 'settings' => [
55 - 'css_class' => 'ivyforms-field-last-name'
56 - ]
79 + 'parentId' => 1,
80 + 'fieldIndex' => 1,
81 + 'defaultValue' => '',
82 + 'position' => 2,
83 + 'optionHide' => false,
84 + 'description' => '',
85 + 'settings' => json_encode(['nameFieldType' => 'nameField2']),
57 86 ],
58 87 [
59 - 'id' => 'email',
88 + 'id' => 4,
89 + 'fieldIndex' => 2,
60 90 'type' => 'email',
61 - 'label' => 'Email Address',
62 - 'placeholder' => 'Enter your email address',
91 + 'label' => BackendStrings::getTemplateStrings()['email_address'],
92 + 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_email_address'],
63 93 'required' => true,
64 94 'validation' => [
65 95 'required' => true,
66 96 'email' => true
@@ -66,15 +96,17 @@
66 96 'email' => true
67 97 ],
68 98 'settings' => [
69 99 'css_class' => 'ivyforms-field-email'
70 - ]
100 + ],
101 + 'position' => 2,
71 102 ],
72 103 [
73 - 'id' => 'subject',
104 + 'id' => 5,
105 + 'fieldIndex' => 3,
74 106 'type' => 'text',
75 - 'label' => 'Subject',
76 - 'placeholder' => 'What is this regarding?',
107 + 'label' => BackendStrings::getTemplateStrings()['subject'],
108 + 'placeholder' => BackendStrings::getTemplateStrings()['what_is_this_regarding'],
77 109 'required' => false,
78 110 'validation' => [
79 111 'required' => false,
80 112 ],
@@ -79,15 +111,17 @@
79 111 'required' => false,
80 112 ],
81 113 'settings' => [
82 114 'css_class' => 'ivyforms-field-subject'
83 - ]
115 + ],
116 + 'position' => 3,
84 117 ],
85 118 [
86 - 'id' => 'message',
119 + 'id' => 6,
120 + 'fieldIndex' => 4,
87 121 'type' => 'textarea',
88 - 'label' => 'Message',
89 - 'placeholder' => 'Please enter your message here...',
122 + 'label' => BackendStrings::getTemplateStrings()['message'],
123 + 'placeholder' => BackendStrings::getTemplateStrings()['please_enter_your_message_here'],
90 124 'required' => false,
91 125 'validation' => [
92 126 'required' => false,
93 127 ],
@@ -92,12 +126,14 @@
92 126 'required' => false,
93 127 ],
94 128 'settings' => [
95 129 'css_class' => 'ivyforms-field-message'
96 - ]
130 + ],
131 + 'position' => 4,
97 132 ]
98 133 ],
99 134 'settings' => []
100 135 ]
101 - ];
136 + ]
137 + );
102 138 }
103 139 }