-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_08.html
147 lines (144 loc) · 16.3 KB
/
example_08.html
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
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Form</title>
<link rel="stylesheet" href="vendor/bootstrap-3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="vendor/bootstrap-3.3.7/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="patch.css">
<style>
.highlight {
padding: 9px 14px;
margin-bottom: 14px;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
border-radius: 4px;
}
</style>
</head>
<body style="margin-bottom: 30px;">
<div class="container">
<div class="page-header">
<h1>
Bootstrap 3 Form from Zend Framework 1
<small>Example 8. Validation states</small>
</h1>
</div>
<div class="row">
<div class="col-xs-12 col-sm-9">
<form enctype="application/x-www-form-urlencoded" class="form-vertical" action="" method="post">
<div class="form-group"><label for="inputSuccess1" class="control-label optional">Input with success</label>
<input type="text" name="inputSuccess1" id="inputSuccess1" value="" class="form-control"></div>
<div class="form-group"><label for="inputWarning1" class="control-label optional">Input with warning</label>
<input type="text" name="inputWarning1" id="inputWarning1" value="" class="form-control"></div>
<div class="form-group"><label for="inputError1" class="control-label required">Input with error</label>
<input type="text" name="inputError1" id="inputError1" value="" class="form-control"></div>
<div class="form-group"><div class="checkbox"><label>
<input type="hidden" name="checkboxSuccess" value="0"><input type="checkbox" name="checkboxSuccess" id="checkboxSuccess" value="1">
Checkbox with success</label></div></div>
<div class="form-group"><div class="checkbox"><label>
<input type="hidden" name="checkboxWarning" value="0"><input type="checkbox" name="checkboxWarning" id="checkboxWarning" value="1">
Checkbox with warning</label></div></div>
<div class="form-group"><div class="checkbox"><label>
<input type="hidden" name="checkboxError" value=""><input type="checkbox" name="checkboxError" id="checkboxError" value="1">
Checkbox with error</label></div></div>
<div class="form-group">
<p class="help-block">Submit this form to display the status</p>
<input type="submit" name="submit" id="submit" value="submit" class="btn btn-primary"></div></form> <hr>
<div class="highlight">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php
<br />
<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">Application_Form_Example8 </span><span style="color: #007700">extends </span><span style="color: #0000BB">Twitter_Bootstrap3_Form_Vertical
<br /></span><span style="color: #007700">{
<br />
<br /> protected </span><span style="color: #0000BB">$_renderElementsStateIcons </span><span style="color: #007700">= </span><span style="color: #0000BB">false</span><span style="color: #007700">;
<br />
<br /> public function </span><span style="color: #0000BB">init</span><span style="color: #007700">()
<br /> {
<br /> </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">addElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'text'</span><span style="color: #007700">, </span><span style="color: #DD0000">'inputSuccess1'</span><span style="color: #007700">, [
<br /> </span><span style="color: #DD0000">'label' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Input with success'</span><span style="color: #007700">,
<br /> ]);
<br />
<br /> </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">addElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'text'</span><span style="color: #007700">, </span><span style="color: #DD0000">'inputWarning1'</span><span style="color: #007700">, [
<br /> </span><span style="color: #DD0000">'label' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Input with warning'</span><span style="color: #007700">,
<br /> ]);
<br />
<br /> </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">addElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'text'</span><span style="color: #007700">, </span><span style="color: #DD0000">'inputError1'</span><span style="color: #007700">, [
<br /> </span><span style="color: #DD0000">'label' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Input with error'</span><span style="color: #007700">,
<br /> </span><span style="color: #DD0000">'required' </span><span style="color: #007700">=> </span><span style="color: #0000BB">true</span><span style="color: #007700">,
<br /> ]);
<br />
<br /> </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">addElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'checkbox'</span><span style="color: #007700">, </span><span style="color: #DD0000">'checkboxSuccess'</span><span style="color: #007700">, [
<br /> </span><span style="color: #DD0000">'label' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Checkbox with success'</span><span style="color: #007700">,
<br /> ]);
<br />
<br /> </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">addElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'checkbox'</span><span style="color: #007700">, </span><span style="color: #DD0000">'checkboxWarning'</span><span style="color: #007700">, [
<br /> </span><span style="color: #DD0000">'label' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Checkbox with warning'</span><span style="color: #007700">,
<br /> ]);
<br />
<br /> </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">addElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'checkbox'</span><span style="color: #007700">, </span><span style="color: #DD0000">'checkboxError'</span><span style="color: #007700">, [
<br /> </span><span style="color: #DD0000">'label' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Checkbox with error'</span><span style="color: #007700">,
<br /> </span><span style="color: #DD0000">'required' </span><span style="color: #007700">=> </span><span style="color: #0000BB">true</span><span style="color: #007700">,
<br /> </span><span style="color: #DD0000">'uncheckedValue' </span><span style="color: #007700">=> </span><span style="color: #0000BB">null</span><span style="color: #007700">,
<br /> ]);
<br />
<br />
<br /> </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">addElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'submit'</span><span style="color: #007700">, </span><span style="color: #DD0000">'submit'</span><span style="color: #007700">, [
<br /> </span><span style="color: #DD0000">'description' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Submit this form to display the status'</span><span style="color: #007700">,
<br /> ]);
<br /> }
<br />
<br /> public function </span><span style="color: #0000BB">isValid</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">)
<br /> {
<br /> </span><span style="color: #0000BB">$valid </span><span style="color: #007700">= </span><span style="color: #0000BB">parent</span><span style="color: #007700">::</span><span style="color: #0000BB">isValid</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">);
<br />
<br /> </span><span style="color: #FF8000">// Additional validation elements for warnings
<br /> </span><span style="color: #0000BB">$inputWarning1 </span><span style="color: #007700">= </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">getElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'inputWarning1'</span><span style="color: #007700">);
<br /> if ( ! </span><span style="color: #0000BB">$inputWarning1</span><span style="color: #007700">-></span><span style="color: #0000BB">hasErrors</span><span style="color: #007700">()) {
<br /> </span><span style="color: #0000BB">$inputWarning1
<br /> </span><span style="color: #007700">-></span><span style="color: #0000BB">setAttrib</span><span style="color: #007700">(</span><span style="color: #DD0000">'warning'</span><span style="color: #007700">, [</span><span style="color: #DD0000">'Warning message'</span><span style="color: #007700">])
<br /> -></span><span style="color: #0000BB">setAttrib</span><span style="color: #007700">(</span><span style="color: #DD0000">'success'</span><span style="color: #007700">, </span><span style="color: #0000BB">null</span><span style="color: #007700">);
<br /> }
<br />
<br /> </span><span style="color: #0000BB">$checkboxWarning </span><span style="color: #007700">= </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">getElement</span><span style="color: #007700">(</span><span style="color: #DD0000">'checkboxWarning'</span><span style="color: #007700">);
<br /> if ( ! </span><span style="color: #0000BB">$checkboxWarning</span><span style="color: #007700">-></span><span style="color: #0000BB">hasErrors</span><span style="color: #007700">()) {
<br /> </span><span style="color: #0000BB">$checkboxWarning
<br /> </span><span style="color: #007700">-></span><span style="color: #0000BB">setAttrib</span><span style="color: #007700">(</span><span style="color: #DD0000">'warning'</span><span style="color: #007700">, [</span><span style="color: #DD0000">'Warning message'</span><span style="color: #007700">])
<br /> -></span><span style="color: #0000BB">setAttrib</span><span style="color: #007700">(</span><span style="color: #DD0000">'success'</span><span style="color: #007700">, </span><span style="color: #0000BB">null</span><span style="color: #007700">);
<br /> }
<br />
<br /> return </span><span style="color: #0000BB">$valid</span><span style="color: #007700">;
<br /> }
<br />
<br />}</span>
</span>
</code> </div>
</div>
<div class="col-xs-6 col-sm-3">
<div class="list-group">
<a class="list-group-item" href="index.html">All Elements</a>
<a class="list-group-item" href="example_01.html"><small>Example 1.</small> Basic example</a>
<a class="list-group-item" href="example_02.html"><small>Example 2.</small> Inline form</a>
<a class="list-group-item" href="example_03.html"><small>Example 3.</small> With input group addon</a>
<a class="list-group-item" href="example_04.html"><small>Example 4.</small> Horizontal form</a>
<a class="list-group-item" href="example_05.html"><small>Example 5.</small> Checkboxes and radios</a>
<a class="list-group-item" href="example_06.html"><small>Example 6.</small> Disabled state</a>
<a class="list-group-item" href="example_07.html"><small>Example 7.</small> Readonly state</a>
<a class="list-group-item active" href="example_08.html"><small>Example 8.</small> Validation states</a>
<a class="list-group-item" href="example_09.html"><small>Example 9.</small> With optional icons</a>
<a class="list-group-item" href="example_10.html"><small>Example 10.</small> Horizontal form group sizes</a>
<a class="list-group-item" href="example_11.html"><small>Example 11.</small> Optional icons in inline forms</a>
<a class="list-group-item" href="example_12.html"><small>Example 12.</small> Horizontal form group sizes</a>
<a class="list-group-item" href="example_13.html"><small>Example 13.</small> Multicolumns horizontal form</a>
<a class="list-group-item" href="example_14.html"><small>Example 14.</small> Checkboxes and radios</a>
</div>
</div>
</div>
</div>
<script src="vendor/jquery-1.11.2.min.js"></script>
<script src="vendor/bootstrap-3.3.7/js/bootstrap.min.js"></script>
</body>
</html>