← All changes
|
backend/src/Services/Template/CookingClassRegistrationFormTemplate.php
+38
-29
0.8.1
→
1.5.1
View file →
| @@ -3,26 +3,21 @@ | ||
| 3 | 3 | declare(strict_types=1); |
| 4 | 4 | |
| 5 | 5 | namespace IvyForms\Services\Template; |
| 6 | 6 | |
| 7 | -// phpcs:disable PSR1.Files.SideEffects | |
| 8 | -if (!defined('ABSPATH')) { | |
| 9 | - exit; // Exit if accessed directly | |
| 10 | -} | |
| 11 | - | |
| 12 | 7 | use IvyForms\Services\Translations\BackendStrings; |
| 13 | 8 | |
| 9 | +class CookingClassRegistrationFormTemplate | |
| 10 | +{ | |
| 14 | 11 | /** |
| 15 | 12 | * Cooking Class Registration Form Template |
| 16 | 13 | */ |
| 17 | -class CookingClassRegistrationFormTemplate | |
| 18 | -{ | |
| 19 | 14 | /** |
| 20 | - * Get the template configuration | |
| 15 | + * Get template metadata (without form_data) | |
| 21 | 16 | * |
| 22 | 17 | * @return array<string, mixed> |
| 23 | 18 | */ |
| 24 | - public static function getTemplate(): array | |
| 19 | + public static function getTemplateMeta(): array | |
| 25 | 20 | { |
| 26 | 21 | return [ |
| 27 | 22 | 'id' => 'cooking_class_registration_form', |
| 28 | 23 | 'name' => BackendStrings::getTemplateStrings()['cooking_class_registration_form'], |
| @@ -31,9 +26,22 @@ | ||
| 31 | 26 | ], |
| 32 | 27 | 'category' => 'registration-forms', |
| 33 | 28 | 'subcategory' => 'class-registration-forms', |
| 34 | 29 | 'is_pro' => false, |
| 35 | - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'cooking-class-registration-form.svg', | |
| 30 | + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'cooking-class-registration-form.svg' | |
| 31 | + ]; | |
| 32 | + } | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * Get the full template including form data | |
| 36 | + * | |
| 37 | + * @return array<string, mixed> | |
| 38 | + */ | |
| 39 | + public static function getTemplate(): array | |
| 40 | + { | |
| 41 | + return array_merge( | |
| 42 | + self::getTemplateMeta(), | |
| 43 | + [ | |
| 36 | 44 | 'form_data' => [ |
| 37 | 45 | 'name' => BackendStrings::getTemplateStrings()['cooking_class_registration_form'], |
| 38 | 46 | 'published' => 1, |
| 39 | 47 | 'showTitle' => 1, |
| @@ -46,9 +54,10 @@ | ||
| 46 | 54 | self::getAdditionalInformationFields() |
| 47 | 55 | ), |
| 48 | 56 | 'settings' => [] |
| 49 | 57 | ] |
| 50 | - ]; | |
| 58 | + ] | |
| 59 | + ); | |
| 51 | 60 | } |
| 52 | 61 | |
| 53 | 62 | /** |
| 54 | 63 | * Personal information fields (name, email, phone) |
| @@ -59,9 +68,9 @@ | ||
| 59 | 68 | { |
| 60 | 69 | return [ |
| 61 | 70 | // Full Name - Parent |
| 62 | 71 | [ |
| 63 | - 'id' => 0, | |
| 72 | + 'id' => 1, | |
| 64 | 73 | 'fieldIndex' => 1, |
| 65 | 74 | 'type' => 'name', |
| 66 | 75 | 'label' => BackendStrings::getTemplateStrings()['full_name'], |
| 67 | 76 | 'parentId' => null, |
| @@ -72,14 +81,14 @@ | ||
| 72 | 81 | 'position' => 1, |
| 73 | 82 | ], |
| 74 | 83 | // First Name - Child of Name Field |
| 75 | 84 | [ |
| 76 | - 'id' => 0, | |
| 85 | + 'id' => 2, | |
| 77 | 86 | 'type' => 'text', |
| 78 | 87 | 'label' => BackendStrings::getTemplateStrings()['first_name'], |
| 79 | 88 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'], |
| 80 | 89 | 'required' => true, |
| 81 | - 'parentId' => 0, | |
| 90 | + 'parentId' => 1, | |
| 82 | 91 | 'fieldIndex' => 1, |
| 83 | 92 | 'defaultValue' => '', |
| 84 | 93 | 'position' => 1, |
| 85 | 94 | 'optionHide' => false, |
| @@ -87,14 +96,14 @@ | ||
| 87 | 96 | 'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| 88 | 97 | ], |
| 89 | 98 | // Last Name - Child of Name Field |
| 90 | 99 | [ |
| 91 | - 'id' => 0, | |
| 100 | + 'id' => 3, | |
| 92 | 101 | 'type' => 'text', |
| 93 | 102 | 'label' => BackendStrings::getTemplateStrings()['last_name'], |
| 94 | 103 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'], |
| 95 | 104 | 'required' => true, |
| 96 | - 'parentId' => 0, | |
| 105 | + 'parentId' => 1, | |
| 97 | 106 | 'fieldIndex' => 1, |
| 98 | 107 | 'defaultValue' => '', |
| 99 | 108 | 'position' => 2, |
| 100 | 109 | 'optionHide' => false, |
| @@ -102,9 +111,9 @@ | ||
| 102 | 111 | 'settings' => json_encode(['nameFieldType' => 'nameField2']), |
| 103 | 112 | ], |
| 104 | 113 | // Email Address |
| 105 | 114 | [ |
| 106 | - 'id' => 0, | |
| 115 | + 'id' => 4, | |
| 107 | 116 | 'fieldIndex' => 2, |
| 108 | 117 | 'type' => 'email', |
| 109 | 118 | 'label' => BackendStrings::getTemplateStrings()['email_address'], |
| 110 | 119 | 'placeholder' => BackendStrings::getTemplateStrings()['email_placeholder'], |
| @@ -114,9 +123,9 @@ | ||
| 114 | 123 | 'position' => 2, |
| 115 | 124 | ], |
| 116 | 125 | // Phone Number |
| 117 | 126 | [ |
| 118 | - 'id' => 0, | |
| 127 | + 'id' => 5, | |
| 119 | 128 | 'fieldIndex' => 3, |
| 120 | 129 | 'type' => 'phone', |
| 121 | 130 | 'label' => BackendStrings::getTemplateStrings()['phone_number'], |
| 122 | 131 | 'placeholder' => BackendStrings::getTemplateStrings()['phone_placeholder'], |
| @@ -137,9 +146,9 @@ | ||
| 137 | 146 | { |
| 138 | 147 | return [ |
| 139 | 148 | // Skill Level |
| 140 | 149 | [ |
| 141 | - 'id' => 0, | |
| 150 | + 'id' => 9, | |
| 142 | 151 | 'fieldIndex' => 4, |
| 143 | 152 | 'type' => 'select', |
| 144 | 153 | 'label' => BackendStrings::getTemplateStrings()['skill_level'], |
| 145 | 154 | 'placeholder' => BackendStrings::getTemplateStrings()['select_skill_level'], |
| @@ -148,9 +157,9 @@ | ||
| 148 | 157 | 'defaultValue' => '', |
| 149 | 158 | 'position' => 4, |
| 150 | 159 | 'fieldOptions' => [ |
| 151 | 160 | [ |
| 152 | - 'id' => 0, | |
| 161 | + 'id' => 6, | |
| 153 | 162 | 'label' => BackendStrings::getTemplateStrings()['beginner'], |
| 154 | 163 | 'value' => 'beginner', |
| 155 | 164 | 'isDefault' => false, |
| 156 | 165 | 'position' => 1 |
| @@ -155,9 +164,9 @@ | ||
| 155 | 164 | 'isDefault' => false, |
| 156 | 165 | 'position' => 1 |
| 157 | 166 | ], |
| 158 | 167 | [ |
| 159 | - 'id' => 0, | |
| 168 | + 'id' => 7, | |
| 160 | 169 | 'label' => BackendStrings::getTemplateStrings()['intermediate'], |
| 161 | 170 | 'value' => 'intermediate', |
| 162 | 171 | 'isDefault' => false, |
| 163 | 172 | 'position' => 2 |
| @@ -162,9 +171,9 @@ | ||
| 162 | 171 | 'isDefault' => false, |
| 163 | 172 | 'position' => 2 |
| 164 | 173 | ], |
| 165 | 174 | [ |
| 166 | - 'id' => 0, | |
| 175 | + 'id' => 8, | |
| 167 | 176 | 'label' => BackendStrings::getTemplateStrings()['advanced'], |
| 168 | 177 | 'value' => 'advanced', |
| 169 | 178 | 'isDefault' => false, |
| 170 | 179 | 'position' => 3 |
| @@ -172,9 +181,9 @@ | ||
| 172 | 181 | ] |
| 173 | 182 | ], |
| 174 | 183 | // Preferred Class Date |
| 175 | 184 | [ |
| 176 | - 'id' => 0, | |
| 185 | + 'id' => 10, | |
| 177 | 186 | 'fieldIndex' => 5, |
| 178 | 187 | 'type' => 'date', |
| 179 | 188 | 'label' => BackendStrings::getTemplateStrings()['preferred_class_date'], |
| 180 | 189 | 'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_class_date'], |
| @@ -197,9 +206,9 @@ | ||
| 197 | 206 | { |
| 198 | 207 | return [ |
| 199 | 208 | // Favorite Cuisine |
| 200 | 209 | [ |
| 201 | - 'id' => 0, | |
| 210 | + 'id' => 11, | |
| 202 | 211 | 'fieldIndex' => 6, |
| 203 | 212 | 'type' => 'text', |
| 204 | 213 | 'label' => BackendStrings::getTemplateStrings()['favorite_cuisine'], |
| 205 | 214 | 'placeholder' => BackendStrings::getTemplateStrings()['favorite_cuisine_placeholder'], |
| @@ -209,9 +218,9 @@ | ||
| 209 | 218 | 'position' => 6, |
| 210 | 219 | ], |
| 211 | 220 | // Dietary Restrictions |
| 212 | 221 | [ |
| 213 | - 'id' => 0, | |
| 222 | + 'id' => 12, | |
| 214 | 223 | 'fieldIndex' => 7, |
| 215 | 224 | 'type' => 'textarea', |
| 216 | 225 | 'label' => BackendStrings::getTemplateStrings()['dietary_restrictions'], |
| 217 | 226 | 'placeholder' => BackendStrings::getTemplateStrings()[ |
| @@ -223,9 +232,9 @@ | ||
| 223 | 232 | 'position' => 7, |
| 224 | 233 | ], |
| 225 | 234 | // Equipment Needed |
| 226 | 235 | [ |
| 227 | - 'id' => 0, | |
| 236 | + 'id' => 15, | |
| 228 | 237 | 'fieldIndex' => 8, |
| 229 | 238 | 'type' => 'checkbox', |
| 230 | 239 | 'label' => BackendStrings::getTemplateStrings()['equipment_needed'], |
| 231 | 240 | 'placeholder' => '', |
| @@ -234,9 +243,9 @@ | ||
| 234 | 243 | 'defaultValue' => '', |
| 235 | 244 | 'position' => 8, |
| 236 | 245 | 'fieldOptions' => [ |
| 237 | 246 | [ |
| 238 | - 'id' => 0, | |
| 247 | + 'id' => 13, | |
| 239 | 248 | 'label' => BackendStrings::getTemplateStrings()['apron'], |
| 240 | 249 | 'value' => 'apron', |
| 241 | 250 | 'isDefault' => false, |
| 242 | 251 | 'position' => 1 |
| @@ -241,9 +250,9 @@ | ||
| 241 | 250 | 'isDefault' => false, |
| 242 | 251 | 'position' => 1 |
| 243 | 252 | ], |
| 244 | 253 | [ |
| 245 | - 'id' => 0, | |
| 254 | + 'id' => 14, | |
| 246 | 255 | 'label' => BackendStrings::getTemplateStrings()['cooking_tools'], |
| 247 | 256 | 'value' => 'cooking_tools', |
| 248 | 257 | 'isDefault' => false, |
| 249 | 258 | 'position' => 2 |
| @@ -262,9 +271,9 @@ | ||
| 262 | 271 | { |
| 263 | 272 | return [ |
| 264 | 273 | // Motivation / Goals |
| 265 | 274 | [ |
| 266 | - 'id' => 0, | |
| 275 | + 'id' => 16, | |
| 267 | 276 | 'fieldIndex' => 9, |
| 268 | 277 | 'type' => 'textarea', |
| 269 | 278 | 'label' => BackendStrings::getTemplateStrings()['motivation_goals'], |
| 270 | 279 | 'placeholder' => BackendStrings::getTemplateStrings()['motivation_goals_placeholder'], |