← All changes
|
backend/src/Services/Template/EventTShirtOrderFormTemplate.php
+47
-37
0.8
→
1.5
View file →
| @@ -1,23 +1,18 @@ | ||
| 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 EventTShirtOrderFormTemplate |
| 13 | 8 | { |
| 14 | 9 | /** |
| 15 | - * Get the event t-shirt order 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' => 'event_tshirt_order_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['event_tshirt_order_form'], |
| @@ -22,10 +17,24 @@ | ||
| 22 | 17 | 'id' => 'event_tshirt_order_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['event_tshirt_order_form'], |
| 24 | 19 | 'description' => BackendStrings::getTemplateStrings()['event_tshirt_order_form_desc'], |
| 25 | 20 | 'category' => 'order-forms', |
| 21 | + 'subcategory' => 'tshirt-order-forms', | |
| 26 | 22 | 'is_pro' => false, |
| 27 | - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'event-tshirt-order-form.svg', | |
| 23 | + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'event-tshirt-order-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()['event_tshirt_order_form'], |
| 30 | 39 | 'published' => 1, |
| 31 | 40 | 'showTitle' => 1, |
| @@ -38,9 +47,10 @@ | ||
| 38 | 47 | self::getAdditionalOptionsFields() |
| 39 | 48 | ), |
| 40 | 49 | 'settings' => [] |
| 41 | 50 | ] |
| 42 | - ]; | |
| 51 | + ] | |
| 52 | + ); | |
| 43 | 53 | } |
| 44 | 54 | |
| 45 | 55 | /** |
| 46 | 56 | * Get requestor information fields |
| @@ -51,9 +61,9 @@ | ||
| 51 | 61 | { |
| 52 | 62 | return [ |
| 53 | 63 | // Name Field - Parent |
| 54 | 64 | [ |
| 55 | - 'id' => 0, | |
| 65 | + 'id' => 1, | |
| 56 | 66 | 'fieldIndex' => 1, |
| 57 | 67 | 'type' => 'name', |
| 58 | 68 | 'label' => BackendStrings::getTemplateStrings()['requestor_name'], |
| 59 | 69 | 'parentId' => null, |
| @@ -64,14 +74,14 @@ | ||
| 64 | 74 | 'position' => 1, |
| 65 | 75 | ], |
| 66 | 76 | // First Name - Child of Name Field |
| 67 | 77 | [ |
| 68 | - 'id' => 0, | |
| 78 | + 'id' => 2, | |
| 69 | 79 | 'type' => 'text', |
| 70 | 80 | 'label' => BackendStrings::getNewFormStrings()['first_name'], |
| 71 | 81 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'], |
| 72 | 82 | 'required' => true, |
| 73 | - 'parentId' => 0, | |
| 83 | + 'parentId' => 1, | |
| 74 | 84 | 'fieldIndex' => 1, |
| 75 | 85 | 'defaultValue' => '', |
| 76 | 86 | 'position' => 1, |
| 77 | 87 | 'optionHide' => false, |
| @@ -79,14 +89,14 @@ | ||
| 79 | 89 | 'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| 80 | 90 | ], |
| 81 | 91 | // Last Name - Child of Name Field |
| 82 | 92 | [ |
| 83 | - 'id' => 0, | |
| 93 | + 'id' => 3, | |
| 84 | 94 | 'type' => 'text', |
| 85 | 95 | 'label' => BackendStrings::getNewFormStrings()['last_name'], |
| 86 | 96 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'], |
| 87 | 97 | 'required' => true, |
| 88 | - 'parentId' => 0, | |
| 98 | + 'parentId' => 1, | |
| 89 | 99 | 'fieldIndex' => 1, |
| 90 | 100 | 'defaultValue' => '', |
| 91 | 101 | 'position' => 2, |
| 92 | 102 | 'optionHide' => false, |
| @@ -94,9 +104,9 @@ | ||
| 94 | 104 | 'settings' => json_encode(['nameFieldType' => 'nameField2']), |
| 95 | 105 | ], |
| 96 | 106 | // Email Address |
| 97 | 107 | [ |
| 98 | - 'id' => 0, | |
| 108 | + 'id' => 4, | |
| 99 | 109 | 'fieldIndex' => 2, |
| 100 | 110 | 'type' => 'email', |
| 101 | 111 | 'label' => BackendStrings::getTemplateStrings()['email_address'], |
| 102 | 112 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_email_address'], |
| @@ -106,9 +116,9 @@ | ||
| 106 | 116 | 'position' => 2, |
| 107 | 117 | ], |
| 108 | 118 | // Phone Number |
| 109 | 119 | [ |
| 110 | - 'id' => 0, | |
| 120 | + 'id' => 5, | |
| 111 | 121 | 'fieldIndex' => 3, |
| 112 | 122 | 'type' => 'phone', |
| 113 | 123 | 'label' => BackendStrings::getTemplateStrings()['phone_number'], |
| 114 | 124 | 'placeholder' => '+1 (_) _-_', |
| @@ -130,9 +140,9 @@ | ||
| 130 | 140 | { |
| 131 | 141 | return [ |
| 132 | 142 | // Event Name |
| 133 | 143 | [ |
| 134 | - 'id' => 0, | |
| 144 | + 'id' => 6, | |
| 135 | 145 | 'fieldIndex' => 4, |
| 136 | 146 | 'type' => 'text', |
| 137 | 147 | 'label' => BackendStrings::getTemplateStrings()['event_name'], |
| 138 | 148 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_event_name'], |
| @@ -153,9 +163,9 @@ | ||
| 153 | 163 | { |
| 154 | 164 | return [ |
| 155 | 165 | // T-Shirt Size |
| 156 | 166 | [ |
| 157 | - 'id' => 0, | |
| 167 | + 'id' => 13, | |
| 158 | 168 | 'fieldIndex' => 5, |
| 159 | 169 | 'type' => 'select', |
| 160 | 170 | 'label' => BackendStrings::getTemplateStrings()['tshirt_size'], |
| 161 | 171 | 'placeholder' => BackendStrings::getTemplateStrings()['select_tshirt_size'], |
| @@ -164,9 +174,9 @@ | ||
| 164 | 174 | 'defaultValue' => '', |
| 165 | 175 | 'position' => 5, |
| 166 | 176 | 'fieldOptions' => [ |
| 167 | 177 | [ |
| 168 | - 'id' => 0, | |
| 178 | + 'id' => 7, | |
| 169 | 179 | 'label' => BackendStrings::getTemplateStrings()['xs'], |
| 170 | 180 | 'value' => 'xs', |
| 171 | 181 | 'isDefault' => false, |
| 172 | 182 | 'position' => 1 |
| @@ -171,9 +181,9 @@ | ||
| 171 | 181 | 'isDefault' => false, |
| 172 | 182 | 'position' => 1 |
| 173 | 183 | ], |
| 174 | 184 | [ |
| 175 | - 'id' => 0, | |
| 185 | + 'id' => 8, | |
| 176 | 186 | 'label' => BackendStrings::getTemplateStrings()['s'], |
| 177 | 187 | 'value' => 's', |
| 178 | 188 | 'isDefault' => false, |
| 179 | 189 | 'position' => 2 |
| @@ -178,9 +188,9 @@ | ||
| 178 | 188 | 'isDefault' => false, |
| 179 | 189 | 'position' => 2 |
| 180 | 190 | ], |
| 181 | 191 | [ |
| 182 | - 'id' => 0, | |
| 192 | + 'id' => 9, | |
| 183 | 193 | 'label' => BackendStrings::getTemplateStrings()['m'], |
| 184 | 194 | 'value' => 'm', |
| 185 | 195 | 'isDefault' => false, |
| 186 | 196 | 'position' => 3 |
| @@ -185,9 +195,9 @@ | ||
| 185 | 195 | 'isDefault' => false, |
| 186 | 196 | 'position' => 3 |
| 187 | 197 | ], |
| 188 | 198 | [ |
| 189 | - 'id' => 0, | |
| 199 | + 'id' => 10, | |
| 190 | 200 | 'label' => BackendStrings::getTemplateStrings()['l'], |
| 191 | 201 | 'value' => 'l', |
| 192 | 202 | 'isDefault' => false, |
| 193 | 203 | 'position' => 4 |
| @@ -192,9 +202,9 @@ | ||
| 192 | 202 | 'isDefault' => false, |
| 193 | 203 | 'position' => 4 |
| 194 | 204 | ], |
| 195 | 205 | [ |
| 196 | - 'id' => 0, | |
| 206 | + 'id' => 11, | |
| 197 | 207 | 'label' => BackendStrings::getTemplateStrings()['xl'], |
| 198 | 208 | 'value' => 'xl', |
| 199 | 209 | 'isDefault' => false, |
| 200 | 210 | 'position' => 5 |
| @@ -199,9 +209,9 @@ | ||
| 199 | 209 | 'isDefault' => false, |
| 200 | 210 | 'position' => 5 |
| 201 | 211 | ], |
| 202 | 212 | [ |
| 203 | - 'id' => 0, | |
| 213 | + 'id' => 12, | |
| 204 | 214 | 'label' => BackendStrings::getTemplateStrings()['xxl'], |
| 205 | 215 | 'value' => 'xxl', |
| 206 | 216 | 'isDefault' => false, |
| 207 | 217 | 'position' => 6 |
| @@ -209,9 +219,9 @@ | ||
| 209 | 219 | ] |
| 210 | 220 | ], |
| 211 | 221 | // Quantity |
| 212 | 222 | [ |
| 213 | - 'id' => 0, | |
| 223 | + 'id' => 14, | |
| 214 | 224 | 'fieldIndex' => 6, |
| 215 | 225 | 'type' => 'number', |
| 216 | 226 | 'label' => BackendStrings::getTemplateStrings()['quantity'], |
| 217 | 227 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_quantity'], |
| @@ -222,9 +232,9 @@ | ||
| 222 | 232 | 'maxValue' => 100, |
| 223 | 233 | ], |
| 224 | 234 | // Event Notes or Special Instructions |
| 225 | 235 | [ |
| 226 | - 'id' => 0, | |
| 236 | + 'id' => 15, | |
| 227 | 237 | 'fieldIndex' => 7, |
| 228 | 238 | 'type' => 'textarea', |
| 229 | 239 | 'label' => BackendStrings::getTemplateStrings()['event_notes_special_instructions'], |
| 230 | 240 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_event_notes'], |
| @@ -235,9 +245,9 @@ | ||
| 235 | 245 | 'rows' => 3, |
| 236 | 246 | ], |
| 237 | 247 | // T-Shirt Color |
| 238 | 248 | [ |
| 239 | - 'id' => 0, | |
| 249 | + 'id' => 22, | |
| 240 | 250 | 'fieldIndex' => 8, |
| 241 | 251 | 'type' => 'select', |
| 242 | 252 | 'label' => BackendStrings::getTemplateStrings()['tshirt_color'], |
| 243 | 253 | 'placeholder' => BackendStrings::getTemplateStrings()['select_tshirt_color'], |
| @@ -246,9 +256,9 @@ | ||
| 246 | 256 | 'defaultValue' => '', |
| 247 | 257 | 'position' => 8, |
| 248 | 258 | 'fieldOptions' => [ |
| 249 | 259 | [ |
| 250 | - 'id' => 0, | |
| 260 | + 'id' => 16, | |
| 251 | 261 | 'label' => BackendStrings::getTemplateStrings()['white'], |
| 252 | 262 | 'value' => 'white', |
| 253 | 263 | 'isDefault' => false, |
| 254 | 264 | 'position' => 1 |
| @@ -253,9 +263,9 @@ | ||
| 253 | 263 | 'isDefault' => false, |
| 254 | 264 | 'position' => 1 |
| 255 | 265 | ], |
| 256 | 266 | [ |
| 257 | - 'id' => 0, | |
| 267 | + 'id' => 17, | |
| 258 | 268 | 'label' => BackendStrings::getTemplateStrings()['black'], |
| 259 | 269 | 'value' => 'black', |
| 260 | 270 | 'isDefault' => false, |
| 261 | 271 | 'position' => 2 |
| @@ -260,9 +270,9 @@ | ||
| 260 | 270 | 'isDefault' => false, |
| 261 | 271 | 'position' => 2 |
| 262 | 272 | ], |
| 263 | 273 | [ |
| 264 | - 'id' => 0, | |
| 274 | + 'id' => 18, | |
| 265 | 275 | 'label' => BackendStrings::getTemplateStrings()['red'], |
| 266 | 276 | 'value' => 'red', |
| 267 | 277 | 'isDefault' => false, |
| 268 | 278 | 'position' => 3 |
| @@ -267,9 +277,9 @@ | ||
| 267 | 277 | 'isDefault' => false, |
| 268 | 278 | 'position' => 3 |
| 269 | 279 | ], |
| 270 | 280 | [ |
| 271 | - 'id' => 0, | |
| 281 | + 'id' => 19, | |
| 272 | 282 | 'label' => BackendStrings::getTemplateStrings()['blue'], |
| 273 | 283 | 'value' => 'blue', |
| 274 | 284 | 'isDefault' => false, |
| 275 | 285 | 'position' => 4 |
| @@ -274,9 +284,9 @@ | ||
| 274 | 284 | 'isDefault' => false, |
| 275 | 285 | 'position' => 4 |
| 276 | 286 | ], |
| 277 | 287 | [ |
| 278 | - 'id' => 0, | |
| 288 | + 'id' => 20, | |
| 279 | 289 | 'label' => BackendStrings::getTemplateStrings()['green'], |
| 280 | 290 | 'value' => 'green', |
| 281 | 291 | 'isDefault' => false, |
| 282 | 292 | 'position' => 5 |
| @@ -281,9 +291,9 @@ | ||
| 281 | 291 | 'isDefault' => false, |
| 282 | 292 | 'position' => 5 |
| 283 | 293 | ], |
| 284 | 294 | [ |
| 285 | - 'id' => 0, | |
| 295 | + 'id' => 21, | |
| 286 | 296 | 'label' => BackendStrings::getTemplateStrings()['custom'], |
| 287 | 297 | 'value' => 'custom', |
| 288 | 298 | 'isDefault' => false, |
| 289 | 299 | 'position' => 6 |
| @@ -302,9 +312,9 @@ | ||
| 302 | 312 | { |
| 303 | 313 | return [ |
| 304 | 314 | // Include Event Logo |
| 305 | 315 | [ |
| 306 | - 'id' => 0, | |
| 316 | + 'id' => 25, | |
| 307 | 317 | 'fieldIndex' => 9, |
| 308 | 318 | 'type' => 'radio', |
| 309 | 319 | 'label' => BackendStrings::getTemplateStrings()['include_event_logo'], |
| 310 | 320 | 'parentId' => null, |
| @@ -311,9 +321,9 @@ | ||
| 311 | 321 | 'position' => 9, |
| 312 | 322 | 'required' => false, |
| 313 | 323 | 'fieldOptions' => [ |
| 314 | 324 | [ |
| 315 | - 'id' => 0, | |
| 325 | + 'id' => 23, | |
| 316 | 326 | 'label' => BackendStrings::getTemplateStrings()['yes'], |
| 317 | 327 | 'value' => 'yes', |
| 318 | 328 | 'isDefault' => false, |
| 319 | 329 | 'position' => 1 |
| @@ -318,9 +328,9 @@ | ||
| 318 | 328 | 'isDefault' => false, |
| 319 | 329 | 'position' => 1 |
| 320 | 330 | ], |
| 321 | 331 | [ |
| 322 | - 'id' => 0, | |
| 332 | + 'id' => 24, | |
| 323 | 333 | 'label' => BackendStrings::getTemplateStrings()['no'], |
| 324 | 334 | 'value' => 'no', |
| 325 | 335 | 'isDefault' => false, |
| 326 | 336 | 'position' => 2 |
| @@ -328,9 +338,9 @@ | ||
| 328 | 338 | ] |
| 329 | 339 | ], |
| 330 | 340 | // Event Date - moved to last position |
| 331 | 341 | [ |
| 332 | - 'id' => 0, | |
| 342 | + 'id' => 26, | |
| 333 | 343 | 'fieldIndex' => 10, |
| 334 | 344 | 'type' => 'date', |
| 335 | 345 | 'label' => BackendStrings::getTemplateStrings()['event_date'], |
| 336 | 346 | 'placeholder' => BackendStrings::getTemplateStrings()['select_event_date'], |