-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.php
153 lines (144 loc) · 3.02 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
// 1. Include the php dependencies/configuration
// (remember to set config params for your environment in conf/config.inc.php)
include_once '../lib/index.inc.php';
// 2. Create the form controls
$name = new Input([
'name' => 'name',
'required' => true,
'message' => 'NAME is required'
]);
$email = new Input([
'type' => 'email',
'label' => 'Email Address',
'name' => 'email',
'required' => true
]);
$address = new Input([
'type' => 'address',
'label' => 'Delivery Address',
'name' => 'address',
'required' => true
]);
$datetime = new Input([
'type' => 'datetime',
'label' => 'Delivery Time',
'name' => 'deliverytime',
'fpOpts' => [
'altFormat' => 'h:i K',
'altInput' => true,
'defaultHour' => date('H') + 1,
'defaultMinute' => 00,
'enableTime' => true,
'minuteIncrement' => 5,
'noCalendar' =>true
],
'required' => true
]);
$crust = new Select([
'name' => 'crust',
'options' => [
'' => 'Choose a crust',
'thin' => 'Thin & Crispy',
'deep' => 'Chicago Deep Dish',
'glutenfree' => 'Gluten Free'
],
'required' => true
]);
$mozzarella = new Input([
'type' => 'radio',
'name' => 'cheese',
'id' => 'mozzarella',
'value' => 'mozzarella',
'checked' => true
]);
$soy = new Input([
'type' => 'radio',
'name' => 'cheese',
'id' => 'soy',
'value' => 'soy',
'label' => 'Soy (vegan)',
'checked' => false
]);
$sausage = new Input([
'type' => 'checkbox',
'name' => 'toppings',
'id' => 'sausage',
'value' => 'sausage'
]);
$pepperoni = new Input([
'type' => 'checkbox',
'name' => 'toppings',
'id' => 'pepperoni',
'value' => 'pepperoni'
]);
$peppers = new Input([
'type' => 'checkbox',
'name' => 'toppings',
'id' => 'peppers',
'value' => 'peppers',
'label' => 'Bell peppers'
]);
$tomato = new Input([
'type' => 'checkbox',
'name' => 'toppings',
'id' => 'tomato',
'value' => 'tomato'
]);
$onion = new Input([
'type' => 'checkbox',
'name' => 'toppings',
'id' => 'onion',
'value' => 'onion'
]);
$instructions = new Textarea([
'label' => 'Special Instructions',
'name' => 'instructions'
]);
// 3. Add the form controls to Form
$form = new Form([
'adminEmail' => '',
'emailSubject' => 'Order form submitted by {{name}}',
'submitButtonText' => 'Order Now',
'successMsg' => 'Thanks for your order.'
]);
$form->addControl($name);
$form->addControl($email);
$form->addControl($address);
$form->addControl($datetime);
$form->addControl($crust);
$form->addGroup([
'controls' => [
$mozzarella,
$soy
],
'label' => 'Type of Cheese'
]);
$form->addGroup([
'arrangement' => 'stacked',
'controls' => [
$sausage,
$pepperoni,
$peppers,
$tomato,
$onion
]
]);
$form->addControl($instructions);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="css/index.css" />
<title>Example</title>
</head>
<body>
<?php
// 4. Render the form
$form->render();
?>
<script src="js/index.js"></script>
</body>
</html>