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

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