← All changes
|
backend/src/Services/Template/WebinarRegistrationFormTemplate.php
+37
-27
0.7
→
1.5
View file →
| @@ -1,31 +1,40 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace IvyForms\Services\Template; |
| 4 | 4 | |
| 5 | -// phpcs:disable PSR1.Files.SideEffects | |
| 6 | -if (!defined('ABSPATH')) { | |
| 7 | - exit; // Exit if accessed directly | |
| 8 | -} | |
| 9 | - | |
| 10 | 5 | use IvyForms\Services\Translations\BackendStrings; |
| 11 | 6 | |
| 12 | 7 | class WebinarRegistrationFormTemplate |
| 13 | 8 | { |
| 14 | 9 | /** |
| 15 | - * Get the webinar registration form template | |
| 10 | + * Get template metadata (without form_data) | |
| 16 | 11 | * |
| 17 | 12 | * @return array<string, mixed> |
| 18 | 13 | */ |
| 19 | - public static function getTemplate(): array | |
| 14 | + public static function getTemplateMeta(): array | |
| 20 | 15 | { |
| 21 | 16 | return [ |
| 22 | 17 | 'id' => 'webinar_registration_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['webinar_registration_form'], |
| 24 | 19 | 'description' => BackendStrings::getTemplateStrings()['webinar_registration_form_desc'], |
| 25 | - 'category' => 'event-registration', | |
| 20 | + 'category' => 'event-registration-forms', | |
| 21 | + 'subcategory' => 'webinar-registration-forms', | |
| 26 | 22 | 'is_pro' => false, |
| 27 | - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'webinar-registration-form.svg', | |
| 23 | + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'webinar-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 | + [ | |
| 28 | 37 | 'form_data' => [ |
| 29 | 38 | 'name' => BackendStrings::getTemplateStrings()['webinar_registration_form'], |
| 30 | 39 | 'published' => 1, |
| 31 | 40 | 'showTitle' => 1, |
| @@ -37,9 +46,10 @@ | ||
| 37 | 46 | self::getAdditionalInformationFields() |
| 38 | 47 | ), |
| 39 | 48 | 'settings' => [] |
| 40 | 49 | ] |
| 41 | - ]; | |
| 50 | + ] | |
| 51 | + ); | |
| 42 | 52 | } |
| 43 | 53 | |
| 44 | 54 | /** |
| 45 | 55 | * Get participant information fields |
| @@ -50,9 +60,9 @@ | ||
| 50 | 60 | { |
| 51 | 61 | return [ |
| 52 | 62 | // Name Field - Parent |
| 53 | 63 | [ |
| 54 | - 'id' => 0, | |
| 64 | + 'id' => 1, | |
| 55 | 65 | 'fieldIndex' => 1, |
| 56 | 66 | 'type' => 'name', |
| 57 | 67 | 'label' => BackendStrings::getTemplateStrings()['full_name'], |
| 58 | 68 | 'parentId' => null, |
| @@ -63,14 +73,14 @@ | ||
| 63 | 73 | 'position' => 1, |
| 64 | 74 | ], |
| 65 | 75 | // First Name - Child of Name Field |
| 66 | 76 | [ |
| 67 | - 'id' => 0, | |
| 77 | + 'id' => 2, | |
| 68 | 78 | 'type' => 'text', |
| 69 | 79 | 'label' => BackendStrings::getNewFormStrings()['first_name'], |
| 70 | 80 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'], |
| 71 | 81 | 'required' => true, |
| 72 | - 'parentId' => 0, | |
| 82 | + 'parentId' => 1, | |
| 73 | 83 | 'fieldIndex' => 1, |
| 74 | 84 | 'defaultValue' => '', |
| 75 | 85 | 'position' => 1, |
| 76 | 86 | 'optionHide' => false, |
| @@ -78,14 +88,14 @@ | ||
| 78 | 88 | 'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| 79 | 89 | ], |
| 80 | 90 | // Last Name - Child of Name Field |
| 81 | 91 | [ |
| 82 | - 'id' => 0, | |
| 92 | + 'id' => 3, | |
| 83 | 93 | 'type' => 'text', |
| 84 | 94 | 'label' => BackendStrings::getNewFormStrings()['last_name'], |
| 85 | 95 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'], |
| 86 | 96 | 'required' => true, |
| 87 | - 'parentId' => 0, | |
| 97 | + 'parentId' => 1, | |
| 88 | 98 | 'fieldIndex' => 1, |
| 89 | 99 | 'defaultValue' => '', |
| 90 | 100 | 'position' => 2, |
| 91 | 101 | 'optionHide' => false, |
| @@ -93,9 +103,9 @@ | ||
| 93 | 103 | 'settings' => json_encode(['nameFieldType' => 'nameField2']), |
| 94 | 104 | ], |
| 95 | 105 | // Email Address |
| 96 | 106 | [ |
| 97 | - 'id' => 0, | |
| 107 | + 'id' => 4, | |
| 98 | 108 | 'fieldIndex' => 2, |
| 99 | 109 | 'type' => 'email', |
| 100 | 110 | 'label' => BackendStrings::getTemplateStrings()['email_address'], |
| 101 | 111 | 'placeholder' => '[email protected]', |
| @@ -116,9 +126,9 @@ | ||
| 116 | 126 | { |
| 117 | 127 | return [ |
| 118 | 128 | // Session Time |
| 119 | 129 | [ |
| 120 | - 'id' => 0, | |
| 130 | + 'id' => 8, | |
| 121 | 131 | 'fieldIndex' => 3, |
| 122 | 132 | 'type' => 'select', |
| 123 | 133 | 'label' => BackendStrings::getTemplateStrings()['session_time'], |
| 124 | 134 | 'placeholder' => BackendStrings::getTemplateStrings()['select_session_time'], |
| @@ -127,9 +137,9 @@ | ||
| 127 | 137 | 'defaultValue' => '', |
| 128 | 138 | 'position' => 3, |
| 129 | 139 | 'fieldOptions' => [ |
| 130 | 140 | [ |
| 131 | - 'id' => 0, | |
| 141 | + 'id' => 5, | |
| 132 | 142 | 'label' => BackendStrings::getTemplateStrings()['morning'], |
| 133 | 143 | 'value' => 'morning', |
| 134 | 144 | 'isDefault' => false, |
| 135 | 145 | 'position' => 1 |
| @@ -134,9 +144,9 @@ | ||
| 134 | 144 | 'isDefault' => false, |
| 135 | 145 | 'position' => 1 |
| 136 | 146 | ], |
| 137 | 147 | [ |
| 138 | - 'id' => 0, | |
| 148 | + 'id' => 6, | |
| 139 | 149 | 'label' => BackendStrings::getTemplateStrings()['afternoon'], |
| 140 | 150 | 'value' => 'afternoon', |
| 141 | 151 | 'isDefault' => false, |
| 142 | 152 | 'position' => 2 |
| @@ -141,9 +151,9 @@ | ||
| 141 | 151 | 'isDefault' => false, |
| 142 | 152 | 'position' => 2 |
| 143 | 153 | ], |
| 144 | 154 | [ |
| 145 | - 'id' => 0, | |
| 155 | + 'id' => 7, | |
| 146 | 156 | 'label' => BackendStrings::getTemplateStrings()['evening'], |
| 147 | 157 | 'value' => 'evening', |
| 148 | 158 | 'isDefault' => false, |
| 149 | 159 | 'position' => 3 |
| @@ -151,9 +161,9 @@ | ||
| 151 | 161 | ] |
| 152 | 162 | ], |
| 153 | 163 | // Participation Type |
| 154 | 164 | [ |
| 155 | - 'id' => 0, | |
| 165 | + 'id' => 11, | |
| 156 | 166 | 'fieldIndex' => 4, |
| 157 | 167 | 'type' => 'radio', |
| 158 | 168 | 'label' => BackendStrings::getTemplateStrings()['participation_type'], |
| 159 | 169 | 'required' => true, |
| @@ -162,9 +172,9 @@ | ||
| 162 | 172 | 'placeholder' => '', |
| 163 | 173 | 'position' => 4, |
| 164 | 174 | 'fieldOptions' => [ |
| 165 | 175 | [ |
| 166 | - 'id' => 0, | |
| 176 | + 'id' => 9, | |
| 167 | 177 | 'label' => BackendStrings::getTemplateStrings()['live'], |
| 168 | 178 | 'value' => 'live', |
| 169 | 179 | 'isDefault' => false, |
| 170 | 180 | 'position' => 1 |
| @@ -169,9 +179,9 @@ | ||
| 169 | 179 | 'isDefault' => false, |
| 170 | 180 | 'position' => 1 |
| 171 | 181 | ], |
| 172 | 182 | [ |
| 173 | - 'id' => 0, | |
| 183 | + 'id' => 10, | |
| 174 | 184 | 'label' => BackendStrings::getTemplateStrings()['recorded'], |
| 175 | 185 | 'value' => 'recorded', |
| 176 | 186 | 'isDefault' => false, |
| 177 | 187 | 'position' => 2 |
| @@ -190,9 +200,9 @@ | ||
| 190 | 200 | { |
| 191 | 201 | return [ |
| 192 | 202 | // Subscribe to Newsletter |
| 193 | 203 | [ |
| 194 | - 'id' => 0, | |
| 204 | + 'id' => 14, | |
| 195 | 205 | 'fieldIndex' => 5, |
| 196 | 206 | 'type' => 'radio', |
| 197 | 207 | 'label' => BackendStrings::getTemplateStrings()['subscribe_to_newsletter'], |
| 198 | 208 | 'required' => false, |
| @@ -201,9 +211,9 @@ | ||
| 201 | 211 | 'placeholder' => '', |
| 202 | 212 | 'position' => 5, |
| 203 | 213 | 'fieldOptions' => [ |
| 204 | 214 | [ |
| 205 | - 'id' => 0, | |
| 215 | + 'id' => 12, | |
| 206 | 216 | 'label' => BackendStrings::getTemplateStrings()['yes'], |
| 207 | 217 | 'value' => 'yes', |
| 208 | 218 | 'isDefault' => false, |
| 209 | 219 | 'position' => 1 |
| @@ -208,9 +218,9 @@ | ||
| 208 | 218 | 'isDefault' => false, |
| 209 | 219 | 'position' => 1 |
| 210 | 220 | ], |
| 211 | 221 | [ |
| 212 | - 'id' => 0, | |
| 222 | + 'id' => 13, | |
| 213 | 223 | 'label' => BackendStrings::getTemplateStrings()['no'], |
| 214 | 224 | 'value' => 'no', |
| 215 | 225 | 'isDefault' => false, |
| 216 | 226 | 'position' => 2 |
| @@ -218,9 +228,9 @@ | ||
| 218 | 228 | ] |
| 219 | 229 | ], |
| 220 | 230 | // Questions for Speaker |
| 221 | 231 | [ |
| 222 | - 'id' => 0, | |
| 232 | + 'id' => 15, | |
| 223 | 233 | 'fieldIndex' => 6, |
| 224 | 234 | 'type' => 'textarea', |
| 225 | 235 | 'label' => BackendStrings::getTemplateStrings()['questions_for_speaker'], |
| 226 | 236 | 'placeholder' => BackendStrings::getTemplateStrings()['write_your_question_here'], |