@@ -56,7 +56,7 @@ public function testFormOpenBasic()
56
56
$ Name = csrf_token ();
57
57
$ expected = <<<EOH
58
58
<form action="http://example.com/index.php/foo/bar" name="form" id="form" method="POST" accept-charset="utf-8">
59
- <input type="hidden" name=" {$ Name }" value=" {$ Value }" style="display:none;" / >
59
+ <input type="hidden" name=" {$ Name }" value=" {$ Value }" style="display:none;">
60
60
61
61
EOH ;
62
62
} else {
@@ -101,7 +101,7 @@ public function testFormOpenWithoutAction()
101
101
$ Name = csrf_token ();
102
102
$ expected = <<<EOH
103
103
<form action="http://example.com/index.php" name="form" id="form" method="POST" accept-charset="utf-8">
104
- <input type="hidden" name=" {$ Name }" value=" {$ Value }" style="display:none;" / >
104
+ <input type="hidden" name=" {$ Name }" value=" {$ Value }" style="display:none;">
105
105
106
106
EOH ;
107
107
} else {
@@ -128,7 +128,7 @@ public function testFormOpenWithoutMethod()
128
128
$ Name = csrf_token ();
129
129
$ expected = <<<EOH
130
130
<form action="http://example.com/index.php/foo/bar" name="form" id="form" method="post" accept-charset="utf-8">
131
- <input type="hidden" name=" {$ Name }" value=" {$ Value }" style="display:none;" / >
131
+ <input type="hidden" name=" {$ Name }" value=" {$ Value }" style="display:none;">
132
132
133
133
EOH ;
134
134
} else {
@@ -155,15 +155,15 @@ public function testFormOpenWithHidden()
155
155
$ Name = csrf_token ();
156
156
$ expected = <<<EOH
157
157
<form action="http://example.com/index.php/foo/bar" name="form" id="form" method="POST" accept-charset="utf-8">
158
- <input type="hidden" name="foo" value="bar" / >
159
- <input type="hidden" name=" {$ Name }" value=" {$ Value }" / >
158
+ <input type="hidden" name="foo" value="bar">
159
+ <input type="hidden" name=" {$ Name }" value=" {$ Value }">
160
160
161
161
EOH ;
162
162
} else {
163
163
$ expected = <<<'EOH'
164
164
<form action="http://example.com/index.php/foo/bar" name="form" id="form" method="POST" accept-charset="utf-8">
165
165
166
- <input type="hidden" name="foo" value="bar" / >
166
+ <input type="hidden" name="foo" value="bar">
167
167
168
168
EOH;
169
169
}
@@ -189,7 +189,7 @@ public function testFormOpenMultipart()
189
189
$ Name = csrf_token ();
190
190
$ expected = <<<EOH
191
191
<form action="http://example.com/index.php/foo/bar" name="form" id="form" method="POST" enctype="multipart/form-data" accept-charset="utf-8">
192
- <input type="hidden" name=" {$ Name }" value=" {$ Value }" style="display:none;" / >
192
+ <input type="hidden" name=" {$ Name }" value=" {$ Value }" style="display:none;">
193
193
194
194
EOH ;
195
195
} else {
@@ -214,7 +214,7 @@ public function testFormHidden()
214
214
{
215
215
$ expected = <<<EOH
216
216
217
- <input type="hidden" name="username" value="johndoe" / > \n
217
+ <input type="hidden" name="username" value="johndoe"> \n
218
218
EOH ;
219
219
$ this ->assertSame ($ expected , form_hidden ('username ' , 'johndoe ' ));
220
220
}
@@ -226,7 +226,7 @@ public function testFormHiddenArrayInput()
226
226
];
227
227
$ expected = <<<'EOH'
228
228
229
- <input type="hidden" name="foo" value="bar" / >
229
+ <input type="hidden" name="foo" value="bar">
230
230
231
231
EOH;
232
232
$ this ->assertSame ($ expected , form_hidden ($ data , null ));
@@ -239,14 +239,34 @@ public function testFormHiddenArrayValues()
239
239
];
240
240
$ expected = <<<'EOH'
241
241
242
- <input type="hidden" name="name[foo]" value="bar" / >
242
+ <input type="hidden" name="name[foo]" value="bar">
243
243
244
244
EOH;
245
245
$ this ->assertSame ($ expected , form_hidden ('name ' , $ data ));
246
246
}
247
247
248
248
public function testFormInput ()
249
249
{
250
+ $ expected = <<<EOH
251
+ <input type="text" name="username" value="johndoe" id="username" maxlength="100" size="50" style="width:50%"> \n
252
+ EOH ;
253
+ $ data = [
254
+ 'name ' => 'username ' ,
255
+ 'id ' => 'username ' ,
256
+ 'value ' => 'johndoe ' ,
257
+ 'maxlength ' => '100 ' ,
258
+ 'size ' => '50 ' ,
259
+ 'style ' => 'width:50% ' ,
260
+ ];
261
+ $ this ->assertSame ($ expected , form_input ($ data ));
262
+ }
263
+
264
+ public function testFormInputXHTML ()
265
+ {
266
+ $ doctypes = config ('DocTypes ' );
267
+ $ default = $ doctypes ->html5 ;
268
+ $ doctypes ->html5 = false ;
269
+
250
270
$ expected = <<<EOH
251
271
<input type="text" name="username" value="johndoe" id="username" maxlength="100" size="50" style="width:50%" /> \n
252
272
EOH ;
@@ -259,12 +279,15 @@ public function testFormInput()
259
279
'style ' => 'width:50% ' ,
260
280
];
261
281
$ this ->assertSame ($ expected , form_input ($ data ));
282
+
283
+ // Reset
284
+ $ doctypes ->html5 = $ default ;
262
285
}
263
286
264
287
public function testFormInputWithExtra ()
265
288
{
266
289
$ expected = <<<EOH
267
- <input type="email" name="identity" value="" id="identity" class="form-control form-control-lg" / > \n
290
+ <input type="email" name="identity" value="" id="identity" class="form-control form-control-lg"> \n
268
291
EOH ;
269
292
$ data = [
270
293
'id ' => 'identity ' ,
@@ -280,17 +303,32 @@ public function testFormInputWithExtra()
280
303
public function testFormPassword ()
281
304
{
282
305
$ expected = <<<EOH
283
- <input type="password" name="password" value="" / > \n
306
+ <input type="password" name="password" value=""> \n
284
307
EOH ;
285
308
$ this ->assertSame ($ expected , form_password ('password ' ));
286
309
}
287
310
288
311
public function testFormUpload ()
289
312
{
313
+ $ expected = <<<EOH
314
+ <input type="file" name="attachment"> \n
315
+ EOH ;
316
+ $ this ->assertSame ($ expected , form_upload ('attachment ' ));
317
+ }
318
+
319
+ public function testFormUploadXHTML ()
320
+ {
321
+ $ doctypes = config ('DocTypes ' );
322
+ $ default = $ doctypes ->html5 ;
323
+ $ doctypes ->html5 = false ;
324
+
290
325
$ expected = <<<EOH
291
326
<input type="file" name="attachment" /> \n
292
327
EOH ;
293
328
$ this ->assertSame ($ expected , form_upload ('attachment ' ));
329
+
330
+ // Reset
331
+ $ doctypes ->html5 = $ default ;
294
332
}
295
333
296
334
public function testFormTextarea ()
@@ -611,10 +649,25 @@ public function testFormFieldsetClose()
611
649
612
650
public function testFormCheckbox ()
613
651
{
652
+ $ expected = <<<EOH
653
+ <input type="checkbox" name="newsletter" value="accept" checked="checked"> \n
654
+ EOH ;
655
+ $ this ->assertSame ($ expected , form_checkbox ('newsletter ' , 'accept ' , true ));
656
+ }
657
+
658
+ public function testFormCheckboxXHTML ()
659
+ {
660
+ $ doctypes = config ('DocTypes ' );
661
+ $ default = $ doctypes ->html5 ;
662
+ $ doctypes ->html5 = false ;
663
+
614
664
$ expected = <<<EOH
615
665
<input type="checkbox" name="newsletter" value="accept" checked="checked" /> \n
616
666
EOH ;
617
667
$ this ->assertSame ($ expected , form_checkbox ('newsletter ' , 'accept ' , true ));
668
+
669
+ // Reset
670
+ $ doctypes ->html5 = $ default ;
618
671
}
619
672
620
673
public function testFormCheckboxArrayData ()
@@ -625,7 +678,7 @@ public function testFormCheckboxArrayData()
625
678
'checked ' => true ,
626
679
];
627
680
$ expected = <<<'EOH'
628
- <input type="checkbox" name="foo" value="bar" checked="checked" / >
681
+ <input type="checkbox" name="foo" value="bar" checked="checked">
629
682
630
683
EOH;
631
684
$ this ->assertSame ($ expected , form_checkbox ($ data ));
@@ -639,7 +692,7 @@ public function testFormCheckboxArrayDataWithCheckedFalse()
639
692
'checked ' => false ,
640
693
];
641
694
$ expected = <<<'EOH'
642
- <input type="checkbox" name="foo" value="bar" / >
695
+ <input type="checkbox" name="foo" value="bar">
643
696
644
697
EOH;
645
698
$ this ->assertSame ($ expected , form_checkbox ($ data ));
@@ -648,15 +701,15 @@ public function testFormCheckboxArrayDataWithCheckedFalse()
648
701
public function testFormRadio ()
649
702
{
650
703
$ expected = <<<EOH
651
- <input type="radio" name="newsletter" value="accept" checked="checked" / > \n
704
+ <input type="radio" name="newsletter" value="accept" checked="checked"> \n
652
705
EOH ;
653
706
$ this ->assertSame ($ expected , form_radio ('newsletter ' , 'accept ' , true ));
654
707
}
655
708
656
709
public function testFormSubmit ()
657
710
{
658
711
$ expected = <<<EOH
659
- <input type="submit" name="mysubmit" value="Submit Post!" / > \n
712
+ <input type="submit" name="mysubmit" value="Submit Post!"> \n
660
713
EOH ;
661
714
$ this ->assertSame ($ expected , form_submit ('mysubmit ' , 'Submit Post! ' ));
662
715
}
@@ -683,7 +736,7 @@ public function testFormLabelWithAttributes()
683
736
public function testFormReset ()
684
737
{
685
738
$ expected = <<<EOH
686
- <input type="reset" name="myreset" value="Reset" / > \n
739
+ <input type="reset" name="myreset" value="Reset"> \n
687
740
EOH ;
688
741
$ this ->assertSame ($ expected , form_reset ('myreset ' , 'Reset ' ));
689
742
}
@@ -724,7 +777,7 @@ public function testFormDatalist()
724
777
'bar1 ' ,
725
778
];
726
779
$ expected = <<<'EOH'
727
- <input type="text" name="foo" value="bar" list="foo_list" / >
780
+ <input type="text" name="foo" value="bar" list="foo_list">
728
781
729
782
<datalist id='foo_list'><option value='foo1'>
730
783
<option value='bar1'>
0 commit comments