PluginProbe
The Innovative Form Builder – IvyForms / 1.1
The Innovative Form Builder – IvyForms v1.1
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 1.1, at backend/src/Services/Template/WorkshopRegistrationFormTemplate.php

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