← All changes
|
backend/src/Services/Template/KitchenUpgradeChangeFormTemplate.php
+42
-21
0.9.1
→
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 KitchenUpgradeChangeFormTemplate |
| 13 | 8 | { |
| 14 | 9 | /** |
| 15 | - * Get the kitchen upgrade change 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' => 'kitchen_upgrade_change_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['kitchen_upgrade_change_form'], |
| @@ -24,9 +19,22 @@ | ||
| 24 | 19 | 'description' => BackendStrings::getTemplateStrings()['kitchen_upgrade_change_form_desc'], |
| 25 | 20 | 'category' => 'order-forms', |
| 26 | 21 | 'subcategory' => 'change-order-forms', |
| 27 | 22 | 'is_pro' => false, |
| 28 | - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'kitchen-upgrade-change-form.svg', | |
| 23 | + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'kitchen-upgrade-change-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 | + [ | |
| 29 | 37 | 'form_data' => [ |
| 30 | 38 | 'name' => BackendStrings::getTemplateStrings()['kitchen_upgrade_change_form'], |
| 31 | 39 | 'published' => 1, |
| 32 | 40 | 'showTitle' => 1, |
| @@ -38,9 +46,10 @@ | ||
| 38 | 46 | self::getAdditionalInformationFields() |
| 39 | 47 | ), |
| 40 | 48 | 'settings' => [] |
| 41 | 49 | ] |
| 42 | - ]; | |
| 50 | + ] | |
| 51 | + ); | |
| 43 | 52 | } |
| 44 | 53 | |
| 45 | 54 | /** |
| 46 | 55 | * Get contact information fields |
| @@ -172,9 +181,10 @@ | ||
| 172 | 181 | 'position' => 1, |
| 173 | 182 | 'hideLabel' => false, |
| 174 | 183 | 'description' => '', |
| 175 | 184 | 'addressType' => 'streetAddress', |
| 176 | - 'settings' => json_encode([ | |
| 185 | + 'settings' => json_encode( | |
| 186 | + [ | |
| 177 | 187 | 'type' => 'streetAddress', |
| 178 | 188 | 'hideLabel' => false, |
| 179 | 189 | 'description' => '', |
| 180 | 190 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'], |
| @@ -179,9 +189,10 @@ | ||
| 179 | 189 | 'description' => '', |
| 180 | 190 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'], |
| 181 | 191 | 'requiredMessage' => '', |
| 182 | 192 | 'visible' => true, |
| 183 | - ]), | |
| 193 | + ] | |
| 194 | + ), | |
| 184 | 195 | ], |
| 185 | 196 | // Address Line 2 - Child of Address Field |
| 186 | 197 | [ |
| 187 | 198 | 'id' => 10, |
| @@ -195,9 +206,10 @@ | ||
| 195 | 206 | 'position' => 2, |
| 196 | 207 | 'hideLabel' => false, |
| 197 | 208 | 'description' => '', |
| 198 | 209 | 'addressType' => 'addressLine2', |
| 199 | - 'settings' => json_encode([ | |
| 210 | + 'settings' => json_encode( | |
| 211 | + [ | |
| 200 | 212 | 'type' => 'addressLine2', |
| 201 | 213 | 'hideLabel' => false, |
| 202 | 214 | 'description' => '', |
| 203 | 215 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'], |
| @@ -202,9 +214,10 @@ | ||
| 202 | 214 | 'description' => '', |
| 203 | 215 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'], |
| 204 | 216 | 'requiredMessage' => '', |
| 205 | 217 | 'visible' => true, |
| 206 | - ]), | |
| 218 | + ] | |
| 219 | + ), | |
| 207 | 220 | ], |
| 208 | 221 | // City - Child of Address Field |
| 209 | 222 | [ |
| 210 | 223 | 'id' => 12, |
| @@ -218,9 +231,10 @@ | ||
| 218 | 231 | 'position' => 3, |
| 219 | 232 | 'hideLabel' => false, |
| 220 | 233 | 'description' => '', |
| 221 | 234 | 'addressType' => 'city', |
| 222 | - 'settings' => json_encode([ | |
| 235 | + 'settings' => json_encode( | |
| 236 | + [ | |
| 223 | 237 | 'type' => 'city', |
| 224 | 238 | 'hideLabel' => false, |
| 225 | 239 | 'description' => '', |
| 226 | 240 | 'placeholder' => BackendStrings::getTemplateStrings()['city'], |
| @@ -225,9 +239,10 @@ | ||
| 225 | 239 | 'description' => '', |
| 226 | 240 | 'placeholder' => BackendStrings::getTemplateStrings()['city'], |
| 227 | 241 | 'requiredMessage' => '', |
| 228 | 242 | 'visible' => true, |
| 229 | - ]), | |
| 243 | + ] | |
| 244 | + ), | |
| 230 | 245 | ], |
| 231 | 246 | // State/Province - Child of Address Field |
| 232 | 247 | [ |
| 233 | 248 | 'id' => 14, |
| @@ -241,9 +256,10 @@ | ||
| 241 | 256 | 'position' => 4, |
| 242 | 257 | 'hideLabel' => false, |
| 243 | 258 | 'description' => '', |
| 244 | 259 | 'addressType' => 'state', |
| 245 | - 'settings' => json_encode([ | |
| 260 | + 'settings' => json_encode( | |
| 261 | + [ | |
| 246 | 262 | 'type' => 'state', |
| 247 | 263 | 'hideLabel' => false, |
| 248 | 264 | 'description' => '', |
| 249 | 265 | 'placeholder' => BackendStrings::getTemplateStrings()['state'], |
| @@ -248,9 +264,10 @@ | ||
| 248 | 264 | 'description' => '', |
| 249 | 265 | 'placeholder' => BackendStrings::getTemplateStrings()['state'], |
| 250 | 266 | 'requiredMessage' => '', |
| 251 | 267 | 'visible' => true, |
| 252 | - ]), | |
| 268 | + ] | |
| 269 | + ), | |
| 253 | 270 | ], |
| 254 | 271 | // Zip/Postal Code - Child of Address Field |
| 255 | 272 | [ |
| 256 | 273 | 'id' => 16, |
| @@ -264,9 +281,10 @@ | ||
| 264 | 281 | 'position' => 5, |
| 265 | 282 | 'hideLabel' => false, |
| 266 | 283 | 'description' => '', |
| 267 | 284 | 'addressType' => 'zip', |
| 268 | - 'settings' => json_encode([ | |
| 285 | + 'settings' => json_encode( | |
| 286 | + [ | |
| 269 | 287 | 'type' => 'zip', |
| 270 | 288 | 'hideLabel' => false, |
| 271 | 289 | 'description' => '', |
| 272 | 290 | 'placeholder' => BackendStrings::getTemplateStrings()['zip'], |
| @@ -271,9 +289,10 @@ | ||
| 271 | 289 | 'description' => '', |
| 272 | 290 | 'placeholder' => BackendStrings::getTemplateStrings()['zip'], |
| 273 | 291 | 'requiredMessage' => '', |
| 274 | 292 | 'visible' => true, |
| 275 | - ]), | |
| 293 | + ] | |
| 294 | + ), | |
| 276 | 295 | ], |
| 277 | 296 | // Country - Child of Address Field |
| 278 | 297 | [ |
| 279 | 298 | 'id' => 18, |
| @@ -287,9 +306,10 @@ | ||
| 287 | 306 | 'position' => 6, |
| 288 | 307 | 'hideLabel' => false, |
| 289 | 308 | 'description' => '', |
| 290 | 309 | 'addressType' => 'country', |
| 291 | - 'settings' => json_encode([ | |
| 310 | + 'settings' => json_encode( | |
| 311 | + [ | |
| 292 | 312 | 'type' => 'country', |
| 293 | 313 | 'hideLabel' => false, |
| 294 | 314 | 'description' => '', |
| 295 | 315 | 'placeholder' => BackendStrings::getTemplateStrings()['select_country'], |
| @@ -294,9 +314,10 @@ | ||
| 294 | 314 | 'description' => '', |
| 295 | 315 | 'placeholder' => BackendStrings::getTemplateStrings()['select_country'], |
| 296 | 316 | 'requiredMessage' => '', |
| 297 | 317 | 'visible' => true, |
| 298 | - ]), | |
| 318 | + ] | |
| 319 | + ), | |
| 299 | 320 | ], |
| 300 | 321 | ]; |
| 301 | 322 | } |
| 302 | 323 | |