| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace IvyForms\Services\Template; |
| 6 |
|
| 7 |
use IvyForms\Services\Translations\BackendStrings; |
| 8 |
|
| 9 |
class CookingClassRegistrationFormTemplate |
| 10 |
{ |
| 11 |
/** |
| 12 |
* Cooking Class Registration Form Template |
| 13 |
*/ |
| 14 |
/** |
| 15 |
* Get template metadata (without form_data) |
| 16 |
* |
| 17 |
* @return array<string, mixed> |
| 18 |
*/ |
| 19 |
public static function getTemplateMeta(): array |
| 20 |
{ |
| 21 |
return [ |
| 22 |
'id' => 'cooking_class_registration_form', |
| 23 |
'name' => BackendStrings::getTemplateStrings()['cooking_class_registration_form'], |
| 24 |
'description' => BackendStrings::getTemplateStrings()[ |
| 25 |
'cooking_class_registration_form_description' |
| 26 |
], |
| 27 |
'category' => 'registration-forms', |
| 28 |
'subcategory' => 'class-registration-forms', |
| 29 |
'is_pro' => false, |
| 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 |
[ |
| 44 |
'form_data' => [ |
| 45 |
'name' => BackendStrings::getTemplateStrings()['cooking_class_registration_form'], |
| 46 |
'published' => 1, |
| 47 |
'showTitle' => 1, |
| 48 |
'storeEntries' => 1, |
| 49 |
'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(), |
| 50 |
'fields' => array_merge( |
| 51 |
self::getPersonalInformationFields(), |
| 52 |
self::getClassDetailsFields(), |
| 53 |
self::getPreferencesFields(), |
| 54 |
self::getAdditionalInformationFields() |
| 55 |
), |
| 56 |
'settings' => [] |
| 57 |
] |
| 58 |
] |
| 59 |
); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Personal information fields (name, email, phone) |
| 64 |
* |
| 65 |
* @return array<int, array<string, mixed>> |
| 66 |
*/ |
| 67 |
private static function getPersonalInformationFields(): array |
| 68 |
{ |
| 69 |
return [ |
| 70 |
// Full Name - Parent |
| 71 |
[ |
| 72 |
'id' => 1, |
| 73 |
'fieldIndex' => 1, |
| 74 |
'type' => 'name', |
| 75 |
'label' => BackendStrings::getTemplateStrings()['full_name'], |
| 76 |
'parentId' => null, |
| 77 |
'defaultValue' => '', |
| 78 |
'placeholder' => '', |
| 79 |
'required' => true, |
| 80 |
'readonly' => false, |
| 81 |
'position' => 1, |
| 82 |
], |
| 83 |
// First Name - Child of Name Field |
| 84 |
[ |
| 85 |
'id' => 2, |
| 86 |
'type' => 'text', |
| 87 |
'label' => BackendStrings::getTemplateStrings()['first_name'], |
| 88 |
'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'], |
| 89 |
'required' => true, |
| 90 |
'parentId' => 1, |
| 91 |
'fieldIndex' => 1, |
| 92 |
'defaultValue' => '', |
| 93 |
'position' => 1, |
| 94 |
'optionHide' => false, |
| 95 |
'description' => '', |
| 96 |
'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| 97 |
], |
| 98 |
// Last Name - Child of Name Field |
| 99 |
[ |
| 100 |
'id' => 3, |
| 101 |
'type' => 'text', |
| 102 |
'label' => BackendStrings::getTemplateStrings()['last_name'], |
| 103 |
'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'], |
| 104 |
'required' => true, |
| 105 |
'parentId' => 1, |
| 106 |
'fieldIndex' => 1, |
| 107 |
'defaultValue' => '', |
| 108 |
'position' => 2, |
| 109 |
'optionHide' => false, |
| 110 |
'description' => '', |
| 111 |
'settings' => json_encode(['nameFieldType' => 'nameField2']), |
| 112 |
], |
| 113 |
// Email Address |
| 114 |
[ |
| 115 |
'id' => 4, |
| 116 |
'fieldIndex' => 2, |
| 117 |
'type' => 'email', |
| 118 |
'label' => BackendStrings::getTemplateStrings()['email_address'], |
| 119 |
'placeholder' => BackendStrings::getTemplateStrings()['email_placeholder'], |
| 120 |
'required' => true, |
| 121 |
'parentId' => null, |
| 122 |
'defaultValue' => '', |
| 123 |
'position' => 2, |
| 124 |
], |
| 125 |
// Phone Number |
| 126 |
[ |
| 127 |
'id' => 5, |
| 128 |
'fieldIndex' => 3, |
| 129 |
'type' => 'phone', |
| 130 |
'label' => BackendStrings::getTemplateStrings()['phone_number'], |
| 131 |
'placeholder' => BackendStrings::getTemplateStrings()['phone_placeholder'], |
| 132 |
'required' => false, |
| 133 |
'parentId' => null, |
| 134 |
'defaultValue' => '', |
| 135 |
'position' => 3, |
| 136 |
], |
| 137 |
]; |
| 138 |
} |
| 139 |
|
| 140 |
/** |
| 141 |
* Class details fields (skill level, preferred date) |
| 142 |
* |
| 143 |
* @return array<int, array<string, mixed>> |
| 144 |
*/ |
| 145 |
private static function getClassDetailsFields(): array |
| 146 |
{ |
| 147 |
return [ |
| 148 |
// Skill Level |
| 149 |
[ |
| 150 |
'id' => 9, |
| 151 |
'fieldIndex' => 4, |
| 152 |
'type' => 'select', |
| 153 |
'label' => BackendStrings::getTemplateStrings()['skill_level'], |
| 154 |
'placeholder' => BackendStrings::getTemplateStrings()['select_skill_level'], |
| 155 |
'required' => true, |
| 156 |
'parentId' => null, |
| 157 |
'defaultValue' => '', |
| 158 |
'position' => 4, |
| 159 |
'fieldOptions' => [ |
| 160 |
[ |
| 161 |
'id' => 6, |
| 162 |
'label' => BackendStrings::getTemplateStrings()['beginner'], |
| 163 |
'value' => 'beginner', |
| 164 |
'isDefault' => false, |
| 165 |
'position' => 1 |
| 166 |
], |
| 167 |
[ |
| 168 |
'id' => 7, |
| 169 |
'label' => BackendStrings::getTemplateStrings()['intermediate'], |
| 170 |
'value' => 'intermediate', |
| 171 |
'isDefault' => false, |
| 172 |
'position' => 2 |
| 173 |
], |
| 174 |
[ |
| 175 |
'id' => 8, |
| 176 |
'label' => BackendStrings::getTemplateStrings()['advanced'], |
| 177 |
'value' => 'advanced', |
| 178 |
'isDefault' => false, |
| 179 |
'position' => 3 |
| 180 |
], |
| 181 |
] |
| 182 |
], |
| 183 |
// Preferred Class Date |
| 184 |
[ |
| 185 |
'id' => 10, |
| 186 |
'fieldIndex' => 5, |
| 187 |
'type' => 'date', |
| 188 |
'label' => BackendStrings::getTemplateStrings()['preferred_class_date'], |
| 189 |
'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_class_date'], |
| 190 |
'required' => true, |
| 191 |
'parentId' => null, |
| 192 |
'defaultValue' => '', |
| 193 |
'position' => 5, |
| 194 |
'dateFieldType' => 'picker', |
| 195 |
'dateFormat' => 'MM/DD/YYYY', |
| 196 |
], |
| 197 |
]; |
| 198 |
} |
| 199 |
|
| 200 |
/** |
| 201 |
* Preferences fields (favorite cuisine, dietary restrictions, equipment) |
| 202 |
* |
| 203 |
* @return array<int, array<string, mixed>> |
| 204 |
*/ |
| 205 |
private static function getPreferencesFields(): array |
| 206 |
{ |
| 207 |
return [ |
| 208 |
// Favorite Cuisine |
| 209 |
[ |
| 210 |
'id' => 11, |
| 211 |
'fieldIndex' => 6, |
| 212 |
'type' => 'text', |
| 213 |
'label' => BackendStrings::getTemplateStrings()['favorite_cuisine'], |
| 214 |
'placeholder' => BackendStrings::getTemplateStrings()['favorite_cuisine_placeholder'], |
| 215 |
'required' => false, |
| 216 |
'parentId' => null, |
| 217 |
'defaultValue' => '', |
| 218 |
'position' => 6, |
| 219 |
], |
| 220 |
// Dietary Restrictions |
| 221 |
[ |
| 222 |
'id' => 12, |
| 223 |
'fieldIndex' => 7, |
| 224 |
'type' => 'textarea', |
| 225 |
'label' => BackendStrings::getTemplateStrings()['dietary_restrictions'], |
| 226 |
'placeholder' => BackendStrings::getTemplateStrings()[ |
| 227 |
'cooking_dietary_restrictions_placeholder' |
| 228 |
], |
| 229 |
'required' => false, |
| 230 |
'parentId' => null, |
| 231 |
'defaultValue' => '', |
| 232 |
'position' => 7, |
| 233 |
], |
| 234 |
// Equipment Needed |
| 235 |
[ |
| 236 |
'id' => 15, |
| 237 |
'fieldIndex' => 8, |
| 238 |
'type' => 'checkbox', |
| 239 |
'label' => BackendStrings::getTemplateStrings()['equipment_needed'], |
| 240 |
'placeholder' => '', |
| 241 |
'required' => false, |
| 242 |
'parentId' => null, |
| 243 |
'defaultValue' => '', |
| 244 |
'position' => 8, |
| 245 |
'fieldOptions' => [ |
| 246 |
[ |
| 247 |
'id' => 13, |
| 248 |
'label' => BackendStrings::getTemplateStrings()['apron'], |
| 249 |
'value' => 'apron', |
| 250 |
'isDefault' => false, |
| 251 |
'position' => 1 |
| 252 |
], |
| 253 |
[ |
| 254 |
'id' => 14, |
| 255 |
'label' => BackendStrings::getTemplateStrings()['cooking_tools'], |
| 256 |
'value' => 'cooking_tools', |
| 257 |
'isDefault' => false, |
| 258 |
'position' => 2 |
| 259 |
], |
| 260 |
] |
| 261 |
], |
| 262 |
]; |
| 263 |
} |
| 264 |
|
| 265 |
/** |
| 266 |
* Additional information fields (motivation/goals) |
| 267 |
* |
| 268 |
* @return array<int, array<string, mixed>> |
| 269 |
*/ |
| 270 |
private static function getAdditionalInformationFields(): array |
| 271 |
{ |
| 272 |
return [ |
| 273 |
// Motivation / Goals |
| 274 |
[ |
| 275 |
'id' => 16, |
| 276 |
'fieldIndex' => 9, |
| 277 |
'type' => 'textarea', |
| 278 |
'label' => BackendStrings::getTemplateStrings()['motivation_goals'], |
| 279 |
'placeholder' => BackendStrings::getTemplateStrings()['motivation_goals_placeholder'], |
| 280 |
'required' => false, |
| 281 |
'parentId' => null, |
| 282 |
'defaultValue' => '', |
| 283 |
'position' => 9, |
| 284 |
], |
| 285 |
]; |
| 286 |
} |
| 287 |
} |
| 288 |
|