PluginProbe
The Innovative Form Builder – IvyForms / 0.6
The Innovative Form Builder – IvyForms v0.6
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 / WorkshopRegistrationFormTemplate.php

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

237 lines 8.3 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 // phpcs:disable PSR1.Files.SideEffects
6 if (!defined('ABSPATH')) {
7 exit; // Exit if accessed directly
8 }
9
10 use IvyForms\Services\Translations\BackendStrings;
11
12 class WorkshopRegistrationFormTemplate
13 {
14 /**
15 * Get the workshop registration form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'workshop_registration_form',
23 'name' => BackendStrings::getTemplateStrings()['workshop_registration_form'],
24 'description' => BackendStrings::getTemplateStrings()['workshop_registration_form_desc'],
25 'category' => 'event-registration',
26 'is_pro' => false,
27 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'workshop-registration-form.svg',
28 'form_data' => [
29 'name' => BackendStrings::getTemplateStrings()['workshop_registration_form'],
30 'published' => 1,
31 'showTitle' => 1,
32 'storeEntries' => 1,
33 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
34 'fields' => array_merge(
35 self::getPersonalInformationFields(),
36 self::getWorkshopSelectionFields(),
37 self::getTandCFields()
38 ),
39 'settings' => []
40 ]
41 ];
42 }
43
44 /**
45 * Get personal information fields
46 *
47 * @return array<int, array<string, mixed>>
48 */
49 private static function getPersonalInformationFields(): array
50 {
51 return [
52 // Name Field - Parent
53 [
54 'id' => 0,
55 'fieldIndex' => 1,
56 'type' => 'name',
57 'label' => BackendStrings::getTemplateStrings()['full_name'],
58 'parentId' => null,
59 'defaultValue' => '',
60 'placeholder' => '',
61 'required' => true,
62 'readonly' => false,
63 'position' => 1,
64 ],
65 // First Name - Child of Name Field
66 [
67 'id' => 0,
68 'type' => 'text',
69 'label' => BackendStrings::getNewFormStrings()['first_name'],
70 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
71 'required' => true,
72 'parentId' => 0,
73 'fieldIndex' => 1,
74 'defaultValue' => '',
75 'position' => 1,
76 'optionHide' => false,
77 'description' => '',
78 'settings' => json_encode(['nameFieldType' => 'nameField1']),
79 ],
80 // Last Name - Child of Name Field
81 [
82 'id' => 0,
83 'type' => 'text',
84 'label' => BackendStrings::getNewFormStrings()['last_name'],
85 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
86 'required' => true,
87 'parentId' => 0,
88 'fieldIndex' => 1,
89 'defaultValue' => '',
90 'position' => 2,
91 'optionHide' => false,
92 'description' => '',
93 'settings' => json_encode(['nameFieldType' => 'nameField2']),
94 ],
95 // Email Address
96 [
97 'id' => 0,
98 'fieldIndex' => 2,
99 'type' => 'email',
100 'label' => BackendStrings::getTemplateStrings()['email_address'],
101 'placeholder' => BackendStrings::getTemplateStrings()['email_address'],
102 'required' => true,
103 'parentId' => null,
104 'defaultValue' => '',
105 'position' => 2,
106 ],
107 ];
108 }
109
110 /**
111 * Get workshop selection fields
112 *
113 * @return array<int, array<string, mixed>>
114 */
115 private static function getWorkshopSelectionFields(): array
116 {
117 return [
118 // Workshop level
119 [
120 'id' => 0,
121 'fieldIndex' => 3,
122 'type' => 'select',
123 'label' => BackendStrings::getTemplateStrings()['workshop_level'],
124 'placeholder' => BackendStrings::getTemplateStrings()['select_workshop_level'],
125 'required' => true,
126 'parentId' => null,
127 'defaultValue' => '',
128 'position' => 3,
129 'fieldOptions' => [
130 [
131 'id' => 0,
132 'label' => BackendStrings::getTemplateStrings()['beginner'],
133 'value' => 'beginner',
134 'isDefault' => false,
135 'position' => 1
136 ],
137 [
138 'id' => 0,
139 'label' => BackendStrings::getTemplateStrings()['intermediate'],
140 'value' => 'intermediate',
141 'isDefault' => false,
142 'position' => 2
143 ],
144 [
145 'id' => 0,
146 'label' => BackendStrings::getTemplateStrings()['advanced'],
147 'value' => 'advanced',
148 'isDefault' => false,
149 'position' => 3
150 ],
151 ]
152 ],
153 // Preferred Date
154 [
155 'id' => 0,
156 'fieldIndex' => 4,
157 'type' => 'select',
158 'label' => BackendStrings::getTemplateStrings()['preferred_date'],
159 'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_date'],
160 'required' => true,
161 'parentId' => null,
162 'defaultValue' => '',
163 'position' => 4,
164 'fieldOptions' => [
165 [
166 'id' => 0,
167 'label' => BackendStrings::getTemplateStrings()['date_1'],
168 'value' => 'date_1',
169 'isDefault' => false,
170 'position' => 1
171 ],
172 [
173 'id' => 0,
174 'label' => BackendStrings::getTemplateStrings()['date_2'],
175 'value' => 'date_2',
176 'isDefault' => false,
177 'position' => 2
178 ],
179 [
180 'id' => 0,
181 'label' => BackendStrings::getTemplateStrings()['date_3'],
182 'value' => 'date_3',
183 'isDefault' => false,
184 'position' => 3
185 ],
186 ],
187 ],
188 // Learning goals
189 [
190 'id' => 0,
191 'fieldIndex' => 5,
192 'type' => 'textarea',
193 'label' => BackendStrings::getTemplateStrings()['learning_goals'],
194 'placeholder' => BackendStrings::getTemplateStrings()['learning_goals_description'],
195 'required' => false,
196 'parentId' => null,
197 'defaultValue' => '',
198 'position' => 5,
199 'rows' => 4,
200 ],
201 ];
202 }
203
204 /**
205 * Get terms and conditions fields
206 *
207 * @return array<int, array<string, mixed>>
208 */
209 private static function getTandCFields(): array
210 {
211 return [
212 // Terms and Conditions
213 [
214 'id' => 0,
215 'fieldIndex' => 6,
216 'type' => 'checkbox',
217 'label' => BackendStrings::getTemplateStrings()['terms_and_conditions'],
218 'placeholder' => '',
219 'required' => true,
220 'requiredMessage' => BackendStrings::getTemplateStrings()['terms_and_conditions_required'],
221 'parentId' => null,
222 'defaultValue' => '',
223 'position' => 6,
224 'fieldOptions' => [
225 [
226 'id' => 0,
227 'label' => BackendStrings::getTemplateStrings()['agree_to_terms'],
228 'value' => 'agree',
229 'isDefault' => false,
230 'position' => 1
231 ],
232 ]
233 ],
234 ];
235 }
236 }
237