This repository has been archived by the owner on Nov 26, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
naming-containers.php
107 lines (79 loc) · 1.79 KB
/
naming-containers.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
<?php
/**
* Nette\Forms naming containers example.
*/
require __DIR__ . '/../../Nette/loader.php';
use Nette\Forms\Form,
Nette\Diagnostics\Debugger;
Debugger::enable();
$form = new Form;
// group First person
$form->addGroup('First person');
$first = $form->addContainer('first');
$first->addText('name', 'Your name:');
$first->addText('email', 'Email:');
$first->addText('street', 'Street:');
$first->addText('city', 'City:');
$first->addSelect('country', 'Country:', array(
'Europe' => array(
'CZ' => 'Czech Republic',
'SK' => 'Slovakia',
),
'US' => 'USA',
'?' => 'other',
));
// group Second person
$form->addGroup('Second person');
$second = $form->addContainer('second');
$second->addText('name', 'Your name:');
$second->addText('email', 'Email:');
$second->addText('street', 'Street:');
$second->addText('city', 'City:');
$second->addSelect('country', 'Country:', array(
'Europe',
'USA',
));
// group for button
$form->addGroup();
$form->addSubmit('submit', 'Send');
if ($form->isSuccess()) {
echo '<h2>Form was submitted and successfully validated</h2>';
Nette\Diagnostics\Dumper::dump($form->values);
exit; // here is usually redirect to another page
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Nette\Forms naming containers example | Nette Framework</title>
<style>
.required label {
font-weight: bold;
}
.error {
color: #D00;
font-weight: bold;
}
fieldset {
padding: .5em;
margin: .5em 0;
background: #E4F1FC;
border: 1px solid #B2D1EB;
}
input.button {
font-size: 120%;
}
th {
width: 10em;
text-align: right;
font-weight: normal;
}
<link rel="stylesheet" media="screen" href="files/style.css" />
</style>
</head>
<body>
<h1>Nette\Forms naming containers example</h1>
<?php echo $form ?>
</body>
</html>