PluginProbe
The Innovative Form Builder – IvyForms / 0.7
The Innovative Form Builder – IvyForms v0.7
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 0.7, at backend/src/Services/Template/DinnerReservationFormTemplate.php

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