← All changes
|
backend/src/Services/Template/DinnerReservationFormTemplate.php
+39
-29
0.7
→
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 DinnerReservationFormTemplate |
| 13 | 8 | { |
| 14 | 9 | /** |
| 15 | - * Get the dinner reservation 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' => 'dinner_reservation_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['dinner_reservation_form'], |
| @@ -22,10 +17,24 @@ | ||
| 22 | 17 | 'id' => 'dinner_reservation_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['dinner_reservation_form'], |
| 24 | 19 | 'description' => BackendStrings::getTemplateStrings()['dinner_reservation_form_desc'], |
| 25 | 20 | 'category' => 'booking-forms', |
| 21 | + 'subcategory' => 'reservation-forms', | |
| 26 | 22 | 'is_pro' => false, |
| 27 | - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'dinner-reservation-form.svg', | |
| 23 | + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'dinner-reservation-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()['dinner_reservation_form'], |
| 30 | 39 | 'published' => 1, |
| 31 | 40 | 'showTitle' => 1, |
| @@ -37,9 +46,10 @@ | ||
| 37 | 46 | self::getAdditionalFields() |
| 38 | 47 | ), |
| 39 | 48 | 'settings' => [] |
| 40 | 49 | ] |
| 41 | - ]; | |
| 50 | + ] | |
| 51 | + ); | |
| 42 | 52 | } |
| 43 | 53 | |
| 44 | 54 | /** |
| 45 | 55 | * Guest information fields (name, email, phone) |
| @@ -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::getTemplateStrings()['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::getTemplateStrings()['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' => BackendStrings::getTemplateStrings()['email_placeholder'], |
| @@ -105,9 +115,9 @@ | ||
| 105 | 115 | 'position' => 2, |
| 106 | 116 | ], |
| 107 | 117 | // Phone Number |
| 108 | 118 | [ |
| 109 | - 'id' => 0, | |
| 119 | + 'id' => 5, | |
| 110 | 120 | 'fieldIndex' => 3, |
| 111 | 121 | 'type' => 'phone', |
| 112 | 122 | 'label' => BackendStrings::getTemplateStrings()['phone_number'], |
| 113 | 123 | 'placeholder' => BackendStrings::getTemplateStrings()['phone_placeholder'], |
| @@ -129,9 +139,9 @@ | ||
| 129 | 139 | { |
| 130 | 140 | return [ |
| 131 | 141 | // Number of Guests |
| 132 | 142 | [ |
| 133 | - 'id' => 0, | |
| 143 | + 'id' => 6, | |
| 134 | 144 | 'fieldIndex' => 4, |
| 135 | 145 | 'type' => 'number', |
| 136 | 146 | 'label' => BackendStrings::getTemplateStrings()['number_of_guests'], |
| 137 | 147 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_total_guests'], |
| @@ -141,9 +151,9 @@ | ||
| 141 | 151 | 'position' => 4, |
| 142 | 152 | ], |
| 143 | 153 | // Seating Preference |
| 144 | 154 | [ |
| 145 | - 'id' => 0, | |
| 155 | + 'id' => 11, | |
| 146 | 156 | 'fieldIndex' => 5, |
| 147 | 157 | 'type' => 'select', |
| 148 | 158 | 'label' => BackendStrings::getTemplateStrings()['seating_preference'], |
| 149 | 159 | 'placeholder' => BackendStrings::getTemplateStrings()['select_seating_preference'], |
| @@ -152,9 +162,9 @@ | ||
| 152 | 162 | 'defaultValue' => '', |
| 153 | 163 | 'position' => 5, |
| 154 | 164 | 'fieldOptions' => [ |
| 155 | 165 | [ |
| 156 | - 'id' => 0, | |
| 166 | + 'id' => 7, | |
| 157 | 167 | 'label' => BackendStrings::getTemplateStrings()['indoor'], |
| 158 | 168 | 'value' => 'indoor', |
| 159 | 169 | 'isDefault' => false, |
| 160 | 170 | 'position' => 1 |
| @@ -159,9 +169,9 @@ | ||
| 159 | 169 | 'isDefault' => false, |
| 160 | 170 | 'position' => 1 |
| 161 | 171 | ], |
| 162 | 172 | [ |
| 163 | - 'id' => 0, | |
| 173 | + 'id' => 8, | |
| 164 | 174 | 'label' => BackendStrings::getTemplateStrings()['outdoor'], |
| 165 | 175 | 'value' => 'outdoor', |
| 166 | 176 | 'isDefault' => false, |
| 167 | 177 | 'position' => 2 |
| @@ -166,9 +176,9 @@ | ||
| 166 | 176 | 'isDefault' => false, |
| 167 | 177 | 'position' => 2 |
| 168 | 178 | ], |
| 169 | 179 | [ |
| 170 | - 'id' => 0, | |
| 180 | + 'id' => 9, | |
| 171 | 181 | 'label' => BackendStrings::getTemplateStrings()['private_room'], |
| 172 | 182 | 'value' => 'private_room', |
| 173 | 183 | 'isDefault' => false, |
| 174 | 184 | 'position' => 3 |
| @@ -173,9 +183,9 @@ | ||
| 173 | 183 | 'isDefault' => false, |
| 174 | 184 | 'position' => 3 |
| 175 | 185 | ], |
| 176 | 186 | [ |
| 177 | - 'id' => 0, | |
| 187 | + 'id' => 10, | |
| 178 | 188 | 'label' => BackendStrings::getTemplateStrings()['window_seat'], |
| 179 | 189 | 'value' => 'window_seat', |
| 180 | 190 | 'isDefault' => false, |
| 181 | 191 | 'position' => 4], |
| @@ -182,9 +192,9 @@ | ||
| 182 | 192 | ] |
| 183 | 193 | ], |
| 184 | 194 | // Reservation Date |
| 185 | 195 | [ |
| 186 | - 'id' => 0, | |
| 196 | + 'id' => 12, | |
| 187 | 197 | 'fieldIndex' => 6, |
| 188 | 198 | 'type' => 'date', |
| 189 | 199 | 'label' => BackendStrings::getTemplateStrings()['reservation_date'], |
| 190 | 200 | 'placeholder' => BackendStrings::getTemplateStrings()['select_reservation_date'], |
| @@ -196,9 +206,9 @@ | ||
| 196 | 206 | 'dateFormat' => 'MM/DD/YYYY', |
| 197 | 207 | ], |
| 198 | 208 | // Reservation Time |
| 199 | 209 | [ |
| 200 | - 'id' => 0, | |
| 210 | + 'id' => 13, | |
| 201 | 211 | 'fieldIndex' => 7, |
| 202 | 212 | 'type' => 'time', |
| 203 | 213 | 'label' => BackendStrings::getTemplateStrings()['reservation_time'], |
| 204 | 214 | 'placeholder' => BackendStrings::getTemplateStrings()['select_reservation_time'], |
| @@ -221,9 +231,9 @@ | ||
| 221 | 231 | { |
| 222 | 232 | return [ |
| 223 | 233 | // Special Requests |
| 224 | 234 | [ |
| 225 | - 'id' => 0, | |
| 235 | + 'id' => 14, | |
| 226 | 236 | 'fieldIndex' => 8, |
| 227 | 237 | 'type' => 'textarea', |
| 228 | 238 | 'label' => BackendStrings::getTemplateStrings()['special_requests'], |
| 229 | 239 | 'placeholder' => BackendStrings::getTemplateStrings()['special_requests_placeholder'], |
| @@ -234,9 +244,9 @@ | ||
| 234 | 244 | 'rows' => 4, |
| 235 | 245 | ], |
| 236 | 246 | // Occasion |
| 237 | 247 | [ |
| 238 | - 'id' => 0, | |
| 248 | + 'id' => 18, | |
| 239 | 249 | 'fieldIndex' => 9, |
| 240 | 250 | 'type' => 'checkbox', |
| 241 | 251 | 'label' => BackendStrings::getTemplateStrings()['occasion_question'], |
| 242 | 252 | 'parentId' => null, |
| @@ -245,9 +255,9 @@ | ||
| 245 | 255 | 'defaultValue' => '', |
| 246 | 256 | 'placeholder' => '', |
| 247 | 257 | 'fieldOptions' => [ |
| 248 | 258 | [ |
| 249 | - 'id' => 0, | |
| 259 | + 'id' => 15, | |
| 250 | 260 | 'label' => BackendStrings::getTemplateStrings()['birthday'], |
| 251 | 261 | 'value' => 'birthday', |
| 252 | 262 | 'isDefault' => false, |
| 253 | 263 | 'position' => 1 |
| @@ -252,9 +262,9 @@ | ||
| 252 | 262 | 'isDefault' => false, |
| 253 | 263 | 'position' => 1 |
| 254 | 264 | ], |
| 255 | 265 | [ |
| 256 | - 'id' => 0, | |
| 266 | + 'id' => 16, | |
| 257 | 267 | 'label' => BackendStrings::getTemplateStrings()['anniversary'], |
| 258 | 268 | 'value' => 'anniversary', |
| 259 | 269 | 'isDefault' => false, |
| 260 | 270 | 'position' => 2 |
| @@ -259,9 +269,9 @@ | ||
| 259 | 269 | 'isDefault' => false, |
| 260 | 270 | 'position' => 2 |
| 261 | 271 | ], |
| 262 | 272 | [ |
| 263 | - 'id' => 0, | |
| 273 | + 'id' => 17, | |
| 264 | 274 | 'label' => BackendStrings::getTemplateStrings()['other'], |
| 265 | 275 | 'value' => 'other', |
| 266 | 276 | 'isDefault' => false, |
| 267 | 277 | 'position' => 3 |