File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1212use TypiCMS \Form \Elements \FormOpen ;
1313use TypiCMS \Form \Elements \Hidden ;
1414use TypiCMS \Form \Elements \Label ;
15+ use TypiCMS \Form \Elements \Number ;
1516use TypiCMS \Form \Elements \Password ;
1617use TypiCMS \Form \Elements \RadioButton ;
1718use TypiCMS \Form \Elements \Select ;
@@ -79,6 +80,17 @@ public function text($name)
7980 return $ text ;
8081 }
8182
83+ public function number ($ name )
84+ {
85+ $ number = new Number ($ name );
86+
87+ if (!is_null ($ value = $ this ->getValueFor ($ name ))) {
88+ $ number ->value ($ value );
89+ }
90+
91+ return $ number ;
92+ }
93+
8294 public function date ($ name )
8395 {
8496 $ date = new Date ($ name );
Original file line number Diff line number Diff line change @@ -50,6 +50,16 @@ public function testBindTextWithIntegerZero()
5050 $ this ->assertEquals ($ expected , $ result );
5151 }
5252
53+ public function testBindNumber ()
54+ {
55+ $ object = $ this ->getStubObject ();
56+ $ this ->form ->bind ($ object );
57+
58+ $ expected = '<input type="number" name="number" value="0"> ' ;
59+ $ result = (string ) $ this ->form ->number ('number ' );
60+ $ this ->assertEquals ($ expected , $ result );
61+ }
62+
5363 public function testBindDate ()
5464 {
5565 $ object = $ this ->getStubObject ();
Original file line number Diff line number Diff line change @@ -45,6 +45,17 @@ public function testTextBox()
4545 $ this ->assertEquals ($ expected , $ result );
4646 }
4747
48+ public function testNumber ()
49+ {
50+ $ expected = '<input type="number" name="number"> ' ;
51+ $ result = (string ) $ this ->form ->number ('number ' );
52+ $ this ->assertEquals ($ expected , $ result );
53+
54+ $ expected = '<input type="number" name="age"> ' ;
55+ $ result = (string ) $ this ->form ->number ('age ' );
56+ $ this ->assertEquals ($ expected , $ result );
57+ }
58+
4859 public function testPassword ()
4960 {
5061 $ expected = '<input type="password" name="password"> ' ;
You can’t perform that action at this time.
0 commit comments