| 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 EventRegistrationTemplate |
| 13 |
{ |
| 14 |
/** |
| 15 |
* Get the event registration form template |
| 16 |
* |
| 17 |
* @return array<string, mixed> |
| 18 |
*/ |
| 19 |
public static function getTemplate(): array |
| 20 |
{ |
| 21 |
return [ |
| 22 |
'id' => 'event_registration', |
| 23 |
'name' => BackendStrings::getTemplateStrings()['event_registration'], |
| 24 |
'description' => BackendStrings::getTemplateStrings()['event_registration_desc'], |
| 25 |
'category' => 'event-registration', |
| 26 |
'is_pro' => false, |
| 27 |
'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'event-registration.svg', |
| 28 |
'form_data' => [ |
| 29 |
'name' => BackendStrings::getTemplateStrings()['event_registration'], |
| 30 |
'published' => 1, |
| 31 |
'showTitle' => 1, |
| 32 |
'storeEntries' => 1, |
| 33 |
'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(), |
| 34 |
'fields' => array_merge( |
| 35 |
self::getPersonalInformationFields(), |
| 36 |
self::getEventDetailsFields(), |
| 37 |
self::getSessionPreferencesFields(), |
| 38 |
self::getAdditionalPreferencesFields() |
| 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()['enter_your_email_address'], |
| 103 |
'required' => true, |
| 104 |
'parentId' => null, |
| 105 |
'defaultValue' => '', |
| 106 |
'position' => 2, |
| 107 |
], |
| 108 |
]; |
| 109 |
} |
| 110 |
|
| 111 |
/** |
| 112 |
* Get event details fields |
| 113 |
* |
| 114 |
* @return array<int, array<string, mixed>> |
| 115 |
*/ |
| 116 |
private static function getEventDetailsFields(): array |
| 117 |
{ |
| 118 |
return [ |
| 119 |
// Event Type |
| 120 |
[ |
| 121 |
'id' => 0, |
| 122 |
'fieldIndex' => 3, |
| 123 |
'type' => 'select', |
| 124 |
'label' => BackendStrings::getTemplateStrings()['event_type'], |
| 125 |
'placeholder' => BackendStrings::getTemplateStrings()['select_event_type'], |
| 126 |
'required' => true, |
| 127 |
'parentId' => null, |
| 128 |
'defaultValue' => '', |
| 129 |
'position' => 3, |
| 130 |
'fieldOptions' => [ |
| 131 |
[ |
| 132 |
'id' => 0, |
| 133 |
'label' => BackendStrings::getTemplateStrings()['conference'], |
| 134 |
'value' => 'conference', |
| 135 |
'isDefault' => false, |
| 136 |
'position' => 1 |
| 137 |
], |
| 138 |
[ |
| 139 |
'id' => 0, |
| 140 |
'label' => BackendStrings::getTemplateStrings()['workshop'], |
| 141 |
'value' => 'workshop', |
| 142 |
'isDefault' => false, |
| 143 |
'position' => 2 |
| 144 |
], |
| 145 |
[ |
| 146 |
'id' => 0, |
| 147 |
'label' => BackendStrings::getTemplateStrings()['seminar'], |
| 148 |
'value' => 'seminar', |
| 149 |
'isDefault' => false, |
| 150 |
'position' => 3 |
| 151 |
], |
| 152 |
[ |
| 153 |
'id' => 0, |
| 154 |
'label' => BackendStrings::getTemplateStrings()['networking_event'], |
| 155 |
'value' => 'networking_event', |
| 156 |
'isDefault' => false, |
| 157 |
'position' => 4 |
| 158 |
], |
| 159 |
[ |
| 160 |
'id' => 0, |
| 161 |
'label' => BackendStrings::getTemplateStrings()['other'], |
| 162 |
'value' => 'other', |
| 163 |
'isDefault' => false, |
| 164 |
'position' => 5 |
| 165 |
], |
| 166 |
] |
| 167 |
], |
| 168 |
// Attendance Type |
| 169 |
[ |
| 170 |
'id' => 0, |
| 171 |
'fieldIndex' => 4, |
| 172 |
'type' => 'select', |
| 173 |
'label' => BackendStrings::getTemplateStrings()['attendance_type'], |
| 174 |
'placeholder' => BackendStrings::getTemplateStrings()['select_attendance_type'], |
| 175 |
'required' => true, |
| 176 |
'parentId' => null, |
| 177 |
'defaultValue' => '', |
| 178 |
'position' => 4, |
| 179 |
'fieldOptions' => [ |
| 180 |
[ |
| 181 |
'id' => 0, |
| 182 |
'label' => BackendStrings::getTemplateStrings()['in_person'], |
| 183 |
'value' => 'in_person', |
| 184 |
'isDefault' => false, |
| 185 |
'position' => 1 |
| 186 |
], |
| 187 |
[ |
| 188 |
'id' => 0, |
| 189 |
'label' => BackendStrings::getTemplateStrings()['virtual'], |
| 190 |
'value' => 'virtual', |
| 191 |
'isDefault' => false, |
| 192 |
'position' => 2 |
| 193 |
], |
| 194 |
[ |
| 195 |
'id' => 0, |
| 196 |
'label' => BackendStrings::getTemplateStrings()['hybrid'], |
| 197 |
'value' => 'hybrid', |
| 198 |
'isDefault' => false, |
| 199 |
'position' => 3 |
| 200 |
], |
| 201 |
] |
| 202 |
], |
| 203 |
// Role / Participant Type |
| 204 |
[ |
| 205 |
'id' => 0, |
| 206 |
'fieldIndex' => 5, |
| 207 |
'type' => 'select', |
| 208 |
'label' => BackendStrings::getTemplateStrings()['role_participant_type'], |
| 209 |
'placeholder' => BackendStrings::getTemplateStrings()['select_role'], |
| 210 |
'required' => true, |
| 211 |
'parentId' => null, |
| 212 |
'defaultValue' => '', |
| 213 |
'position' => 5, |
| 214 |
'fieldOptions' => [ |
| 215 |
[ |
| 216 |
'id' => 0, |
| 217 |
'label' => BackendStrings::getTemplateStrings()['volunteer'], |
| 218 |
'value' => 'volunteer', |
| 219 |
'isDefault' => false, |
| 220 |
'position' => 1 |
| 221 |
], |
| 222 |
[ |
| 223 |
'id' => 0, |
| 224 |
'label' => BackendStrings::getTemplateStrings()['delegate'], |
| 225 |
'value' => 'delegate', |
| 226 |
'isDefault' => false, |
| 227 |
'position' => 2 |
| 228 |
], |
| 229 |
[ |
| 230 |
'id' => 0, |
| 231 |
'label' => BackendStrings::getTemplateStrings()['partner'], |
| 232 |
'value' => 'partner', |
| 233 |
'isDefault' => false, |
| 234 |
'position' => 3 |
| 235 |
], |
| 236 |
[ |
| 237 |
'id' => 0, |
| 238 |
'label' => BackendStrings::getTemplateStrings()['speaker'], |
| 239 |
'value' => 'speaker', |
| 240 |
'isDefault' => false, |
| 241 |
'position' => 4 |
| 242 |
], |
| 243 |
[ |
| 244 |
'id' => 0, |
| 245 |
'label' => BackendStrings::getTemplateStrings()['attendee'], |
| 246 |
'value' => 'attendee', |
| 247 |
'isDefault' => false, |
| 248 |
'position' => 5 |
| 249 |
], |
| 250 |
[ |
| 251 |
'id' => 0, |
| 252 |
'label' => BackendStrings::getTemplateStrings()['other'], |
| 253 |
'value' => 'other', |
| 254 |
'isDefault' => false, |
| 255 |
'position' => 6 |
| 256 |
], |
| 257 |
] |
| 258 |
], |
| 259 |
// Organization / Company Name |
| 260 |
[ |
| 261 |
'id' => 0, |
| 262 |
'fieldIndex' => 6, |
| 263 |
'type' => 'text', |
| 264 |
'label' => BackendStrings::getTemplateStrings()['organization_company_name'], |
| 265 |
'placeholder' => '', |
| 266 |
'required' => false, |
| 267 |
'parentId' => null, |
| 268 |
'defaultValue' => '', |
| 269 |
'position' => 6, |
| 270 |
], |
| 271 |
// Job Title |
| 272 |
[ |
| 273 |
'id' => 0, |
| 274 |
'fieldIndex' => 7, |
| 275 |
'type' => 'text', |
| 276 |
'label' => BackendStrings::getTemplateStrings()['job_title'], |
| 277 |
'placeholder' => '', |
| 278 |
'required' => false, |
| 279 |
'parentId' => null, |
| 280 |
'defaultValue' => '', |
| 281 |
'position' => 7, |
| 282 |
], |
| 283 |
]; |
| 284 |
} |
| 285 |
|
| 286 |
/** |
| 287 |
* Get session preferences fields |
| 288 |
* |
| 289 |
* @return array<int, array<string, mixed>> |
| 290 |
*/ |
| 291 |
private static function getSessionPreferencesFields(): array |
| 292 |
{ |
| 293 |
return [ |
| 294 |
// Morning Session |
| 295 |
[ |
| 296 |
'id' => 0, |
| 297 |
'fieldIndex' => 8, |
| 298 |
'type' => 'checkbox', |
| 299 |
'label' => BackendStrings::getTemplateStrings()['morning_session'], |
| 300 |
'required' => false, |
| 301 |
'parentId' => null, |
| 302 |
'defaultValue' => '', |
| 303 |
'position' => 8, |
| 304 |
'fieldOptions' => [ |
| 305 |
[ |
| 306 |
'id' => 0, |
| 307 |
'label' => BackendStrings::getTemplateStrings()['morning_session'], |
| 308 |
'value' => 'morning_session', |
| 309 |
'isDefault' => false, |
| 310 |
'position' => 1 |
| 311 |
], |
| 312 |
] |
| 313 |
], |
| 314 |
// Afternoon Session |
| 315 |
[ |
| 316 |
'id' => 0, |
| 317 |
'fieldIndex' => 9, |
| 318 |
'type' => 'checkbox', |
| 319 |
'label' => BackendStrings::getTemplateStrings()['afternoon_session'], |
| 320 |
'required' => false, |
| 321 |
'parentId' => null, |
| 322 |
'defaultValue' => '', |
| 323 |
'position' => 9, |
| 324 |
'fieldOptions' => [ |
| 325 |
[ |
| 326 |
'id' => 0, |
| 327 |
'label' => BackendStrings::getTemplateStrings()['afternoon_session'], |
| 328 |
'value' => 'afternoon_session', |
| 329 |
'isDefault' => false, |
| 330 |
'position' => 1 |
| 331 |
], |
| 332 |
] |
| 333 |
], |
| 334 |
// Networking Mixer |
| 335 |
[ |
| 336 |
'id' => 0, |
| 337 |
'fieldIndex' => 10, |
| 338 |
'type' => 'checkbox', |
| 339 |
'label' => BackendStrings::getTemplateStrings()['networking_mixer'], |
| 340 |
'required' => false, |
| 341 |
'parentId' => null, |
| 342 |
'defaultValue' => '', |
| 343 |
'position' => 10, |
| 344 |
'fieldOptions' => [ |
| 345 |
[ |
| 346 |
'id' => 0, |
| 347 |
'label' => BackendStrings::getTemplateStrings()['networking_mixer'], |
| 348 |
'value' => 'networking_mixer', |
| 349 |
'isDefault' => false, |
| 350 |
'position' => 1 |
| 351 |
], |
| 352 |
] |
| 353 |
], |
| 354 |
// Keynote Only |
| 355 |
[ |
| 356 |
'id' => 0, |
| 357 |
'fieldIndex' => 11, |
| 358 |
'type' => 'checkbox', |
| 359 |
'label' => BackendStrings::getTemplateStrings()['keynote_only'], |
| 360 |
'required' => false, |
| 361 |
'parentId' => null, |
| 362 |
'defaultValue' => '', |
| 363 |
'position' => 11, |
| 364 |
'fieldOptions' => [ |
| 365 |
[ |
| 366 |
'id' => 0, |
| 367 |
'label' => BackendStrings::getTemplateStrings()['keynote_only'], |
| 368 |
'value' => 'keynote_only', |
| 369 |
'isDefault' => false, |
| 370 |
'position' => 1 |
| 371 |
], |
| 372 |
] |
| 373 |
], |
| 374 |
]; |
| 375 |
} |
| 376 |
|
| 377 |
/** |
| 378 |
* Get additional preferences fields |
| 379 |
* |
| 380 |
* @return array<int, array<string, mixed>> |
| 381 |
*/ |
| 382 |
private static function getAdditionalPreferencesFields(): array |
| 383 |
{ |
| 384 |
return [ |
| 385 |
// Meal Preference |
| 386 |
[ |
| 387 |
'id' => 0, |
| 388 |
'fieldIndex' => 12, |
| 389 |
'type' => 'select', |
| 390 |
'label' => BackendStrings::getTemplateStrings()['meal_preference'], |
| 391 |
'placeholder' => BackendStrings::getTemplateStrings()['select_meal_preference'], |
| 392 |
'required' => false, |
| 393 |
'parentId' => null, |
| 394 |
'defaultValue' => '', |
| 395 |
'position' => 12, |
| 396 |
'fieldOptions' => [ |
| 397 |
[ |
| 398 |
'id' => 0, |
| 399 |
'label' => BackendStrings::getTemplateStrings()['vegetarian'], |
| 400 |
'value' => 'vegetarian', |
| 401 |
'isDefault' => false, |
| 402 |
'position' => 1 |
| 403 |
], |
| 404 |
[ |
| 405 |
'id' => 0, |
| 406 |
'label' => BackendStrings::getTemplateStrings()['vegan'], |
| 407 |
'value' => 'vegan', |
| 408 |
'isDefault' => false, |
| 409 |
'position' => 2 |
| 410 |
], |
| 411 |
[ |
| 412 |
'id' => 0, |
| 413 |
'label' => BackendStrings::getTemplateStrings()['gluten_free'], |
| 414 |
'value' => 'gluten_free', |
| 415 |
'isDefault' => false, |
| 416 |
'position' => 3 |
| 417 |
], |
| 418 |
[ |
| 419 |
'id' => 0, |
| 420 |
'label' => BackendStrings::getTemplateStrings()['no_preference'], |
| 421 |
'value' => 'no_preference', |
| 422 |
'isDefault' => false, |
| 423 |
'position' => 4 |
| 424 |
], |
| 425 |
] |
| 426 |
], |
| 427 |
// T-Shirt Size |
| 428 |
[ |
| 429 |
'id' => 0, |
| 430 |
'fieldIndex' => 13, |
| 431 |
'type' => 'select', |
| 432 |
'label' => BackendStrings::getTemplateStrings()['t_shirt_size'], |
| 433 |
'placeholder' => BackendStrings::getTemplateStrings()['select_t_shirt_size'], |
| 434 |
'required' => false, |
| 435 |
'parentId' => null, |
| 436 |
'defaultValue' => '', |
| 437 |
'position' => 13, |
| 438 |
'fieldOptions' => [ |
| 439 |
[ |
| 440 |
'id' => 0, |
| 441 |
'label' => BackendStrings::getTemplateStrings()['xs'], |
| 442 |
'value' => 'xs', |
| 443 |
'isDefault' => false, |
| 444 |
'position' => 1 |
| 445 |
], |
| 446 |
[ |
| 447 |
'id' => 0, |
| 448 |
'label' => BackendStrings::getTemplateStrings()['s'], |
| 449 |
'value' => 's', |
| 450 |
'isDefault' => false, |
| 451 |
'position' => 2 |
| 452 |
], |
| 453 |
[ |
| 454 |
'id' => 0, |
| 455 |
'label' => BackendStrings::getTemplateStrings()['m'], |
| 456 |
'value' => 'm', |
| 457 |
'isDefault' => false, |
| 458 |
'position' => 3 |
| 459 |
], |
| 460 |
[ |
| 461 |
'id' => 0, |
| 462 |
'label' => BackendStrings::getTemplateStrings()['l'], |
| 463 |
'value' => 'l', |
| 464 |
'isDefault' => false, |
| 465 |
'position' => 4 |
| 466 |
], |
| 467 |
[ |
| 468 |
'id' => 0, |
| 469 |
'label' => BackendStrings::getTemplateStrings()['xl'], |
| 470 |
'value' => 'xl', |
| 471 |
'isDefault' => false, |
| 472 |
'position' => 5 |
| 473 |
], |
| 474 |
[ |
| 475 |
'id' => 0, |
| 476 |
'label' => BackendStrings::getTemplateStrings()['xxl'], |
| 477 |
'value' => 'xxl', |
| 478 |
'isDefault' => false, |
| 479 |
'position' => 6 |
| 480 |
], |
| 481 |
] |
| 482 |
], |
| 483 |
// Do you require special assistance? |
| 484 |
[ |
| 485 |
'id' => 0, |
| 486 |
'fieldIndex' => 14, |
| 487 |
'type' => 'radio', |
| 488 |
'label' => BackendStrings::getTemplateStrings()['require_special_assistance'], |
| 489 |
'required' => false, |
| 490 |
'parentId' => null, |
| 491 |
'defaultValue' => '', |
| 492 |
'placeholder' => '', |
| 493 |
'position' => 14, |
| 494 |
'fieldOptions' => [ |
| 495 |
[ |
| 496 |
'id' => 0, |
| 497 |
'label' => BackendStrings::getTemplateStrings()['yes'], |
| 498 |
'value' => 'yes', |
| 499 |
'isDefault' => false, |
| 500 |
'position' => 1 |
| 501 |
], |
| 502 |
[ |
| 503 |
'id' => 0, |
| 504 |
'label' => BackendStrings::getTemplateStrings()['no'], |
| 505 |
'value' => 'no', |
| 506 |
'isDefault' => false, |
| 507 |
'position' => 2 |
| 508 |
], |
| 509 |
] |
| 510 |
], |
| 511 |
]; |
| 512 |
} |
| 513 |
} |
| 514 |
|