PluginProbe
The Innovative Form Builder – IvyForms / 1.1
The Innovative Form Builder – IvyForms v1.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Template / DinnerReservationFormTemplate.php

DinnerReservationFormTemplate.php in The Innovative Form Builder – IvyForms 1.1, at backend/src/Services/Template/DinnerReservationFormTemplate.php

284 lines 10.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Services\Template;
4
5 use IvyForms\Services\Translations\BackendStrings;
6
7 class DinnerReservationFormTemplate
8 {
9 /**
10 * Get template metadata (without form_data)
11 *
12 * @return array<string, mixed>
13 */
14 public static function getTemplateMeta(): array
15 {
16 return [
17 'id' => 'dinner_reservation_form',
18 'name' => BackendStrings::getTemplateStrings()['dinner_reservation_form'],
19 'description' => BackendStrings::getTemplateStrings()['dinner_reservation_form_desc'],
20 'category' => 'booking-forms',
21 'subcategory' => 'reservation-forms',
22 'is_pro' => false,
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 [
37 'form_data' => [
38 'name' => BackendStrings::getTemplateStrings()['dinner_reservation_form'],
39 'published' => 1,
40 'showTitle' => 1,
41 'storeEntries' => 1,
42 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
43 'fields' => array_merge(
44 self::getGuestInformationFields(),
45 self::getReservationDetailsFields(),
46 self::getAdditionalFields()
47 ),
48 'settings' => []
49 ]
50 ]
51 );
52 }
53
54 /**
55 * Guest information fields (name, email, phone)
56 *
57 * @return array<int, array<string, mixed>>
58 */
59 private static function getGuestInformationFields(): array
60 {
61 return [
62 // Name Field - Parent
63 [
64 'id' => 1,
65 'fieldIndex' => 1,
66 'type' => 'name',
67 'label' => BackendStrings::getTemplateStrings()['full_name'],
68 'parentId' => null,
69 'defaultValue' => '',
70 'placeholder' => '',
71 'required' => true,
72 'readonly' => false,
73 'position' => 1,
74 ],
75 // First Name - Child of Name Field
76 [
77 'id' => 2,
78 'type' => 'text',
79 'label' => BackendStrings::getTemplateStrings()['first_name'],
80 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
81 'required' => true,
82 'parentId' => 1,
83 'fieldIndex' => 1,
84 'defaultValue' => '',
85 'position' => 1,
86 'optionHide' => false,
87 'description' => '',
88 'settings' => json_encode(['nameFieldType' => 'nameField1']),
89 ],
90 // Last Name - Child of Name Field
91 [
92 'id' => 3,
93 'type' => 'text',
94 'label' => BackendStrings::getTemplateStrings()['last_name'],
95 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
96 'required' => true,
97 'parentId' => 1,
98 'fieldIndex' => 1,
99 'defaultValue' => '',
100 'position' => 2,
101 'optionHide' => false,
102 'description' => '',
103 'settings' => json_encode(['nameFieldType' => 'nameField2']),
104 ],
105 // Email Address
106 [
107 'id' => 4,
108 'fieldIndex' => 2,
109 'type' => 'email',
110 'label' => BackendStrings::getTemplateStrings()['email_address'],
111 'placeholder' => BackendStrings::getTemplateStrings()['email_placeholder'],
112 'required' => true,
113 'parentId' => null,
114 'defaultValue' => '',
115 'position' => 2,
116 ],
117 // Phone Number
118 [
119 'id' => 5,
120 'fieldIndex' => 3,
121 'type' => 'phone',
122 'label' => BackendStrings::getTemplateStrings()['phone_number'],
123 'placeholder' => BackendStrings::getTemplateStrings()['phone_placeholder'],
124 'required' => true,
125 'parentId' => null,
126 'defaultValue' => '',
127 'position' => 3,
128 'phoneAutoDetect' => true,
129 ],
130 ];
131 }
132
133 /**
134 * Reservation detail fields (guests, seating, date, time)
135 *
136 * @return array<int, array<string, mixed>>
137 */
138 private static function getReservationDetailsFields(): array
139 {
140 return [
141 // Number of Guests
142 [
143 'id' => 6,
144 'fieldIndex' => 4,
145 'type' => 'number',
146 'label' => BackendStrings::getTemplateStrings()['number_of_guests'],
147 'placeholder' => BackendStrings::getTemplateStrings()['enter_total_guests'],
148 'required' => true,
149 'parentId' => null,
150 'defaultValue' => '',
151 'position' => 4,
152 ],
153 // Seating Preference
154 [
155 'id' => 11,
156 'fieldIndex' => 5,
157 'type' => 'select',
158 'label' => BackendStrings::getTemplateStrings()['seating_preference'],
159 'placeholder' => BackendStrings::getTemplateStrings()['select_seating_preference'],
160 'required' => false,
161 'parentId' => null,
162 'defaultValue' => '',
163 'position' => 5,
164 'fieldOptions' => [
165 [
166 'id' => 7,
167 'label' => BackendStrings::getTemplateStrings()['indoor'],
168 'value' => 'indoor',
169 'isDefault' => false,
170 'position' => 1
171 ],
172 [
173 'id' => 8,
174 'label' => BackendStrings::getTemplateStrings()['outdoor'],
175 'value' => 'outdoor',
176 'isDefault' => false,
177 'position' => 2
178 ],
179 [
180 'id' => 9,
181 'label' => BackendStrings::getTemplateStrings()['private_room'],
182 'value' => 'private_room',
183 'isDefault' => false,
184 'position' => 3
185 ],
186 [
187 'id' => 10,
188 'label' => BackendStrings::getTemplateStrings()['window_seat'],
189 'value' => 'window_seat',
190 'isDefault' => false,
191 'position' => 4],
192 ]
193 ],
194 // Reservation Date
195 [
196 'id' => 12,
197 'fieldIndex' => 6,
198 'type' => 'date',
199 'label' => BackendStrings::getTemplateStrings()['reservation_date'],
200 'placeholder' => BackendStrings::getTemplateStrings()['select_reservation_date'],
201 'required' => true,
202 'parentId' => null,
203 'defaultValue' => '',
204 'position' => 6,
205 'dateFieldType' => 'picker',
206 'dateFormat' => 'MM/DD/YYYY',
207 ],
208 // Reservation Time
209 [
210 'id' => 13,
211 'fieldIndex' => 7,
212 'type' => 'time',
213 'label' => BackendStrings::getTemplateStrings()['reservation_time'],
214 'placeholder' => BackendStrings::getTemplateStrings()['select_reservation_time'],
215 'required' => true,
216 'parentId' => null,
217 'defaultValue' => '',
218 'position' => 7,
219 'timeFieldType' => 'time-picker',
220 'timeFormat' => 'ampm',
221 ],
222 ];
223 }
224
225 /**
226 * Additional information fields (special requests, occasion)
227 *
228 * @return array<int, array<string, mixed>>
229 */
230 private static function getAdditionalFields(): array
231 {
232 return [
233 // Special Requests
234 [
235 'id' => 14,
236 'fieldIndex' => 8,
237 'type' => 'textarea',
238 'label' => BackendStrings::getTemplateStrings()['special_requests'],
239 'placeholder' => BackendStrings::getTemplateStrings()['special_requests_placeholder'],
240 'parentId' => null,
241 'defaultValue' => '',
242 'position' => 8,
243 'required' => false,
244 'rows' => 4,
245 ],
246 // Occasion
247 [
248 'id' => 18,
249 'fieldIndex' => 9,
250 'type' => 'checkbox',
251 'label' => BackendStrings::getTemplateStrings()['occasion_question'],
252 'parentId' => null,
253 'position' => 9,
254 'required' => false,
255 'defaultValue' => '',
256 'placeholder' => '',
257 'fieldOptions' => [
258 [
259 'id' => 15,
260 'label' => BackendStrings::getTemplateStrings()['birthday'],
261 'value' => 'birthday',
262 'isDefault' => false,
263 'position' => 1
264 ],
265 [
266 'id' => 16,
267 'label' => BackendStrings::getTemplateStrings()['anniversary'],
268 'value' => 'anniversary',
269 'isDefault' => false,
270 'position' => 2
271 ],
272 [
273 'id' => 17,
274 'label' => BackendStrings::getTemplateStrings()['other'],
275 'value' => 'other',
276 'isDefault' => false,
277 'position' => 3
278 ],
279 ]
280 ],
281 ];
282 }
283 }
284