From 6a4f601e8b44956489fdfeb43a2e757443b3bd80 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 19 Feb 2015 15:15:32 +0100 Subject: [PATCH] Add number input field. Fixes #4 --- src/FormBuilder.php | 13 +++++++++++++ tests/FormBuilderTest.php | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/FormBuilder.php b/src/FormBuilder.php index 5be6283..ec1ad70 100755 --- a/src/FormBuilder.php +++ b/src/FormBuilder.php @@ -298,6 +298,19 @@ class FormBuilder { return $this->input('email', $name, $value, $options); } + /** + * Create a number input field. + * + * @param string $name + * @param string $value + * @param array $options + * @return string + */ + public function number($name, $value = null, $options = array()) + { + return $this->input('number', $name, $value, $options); + } + /** * Create a url input field. * diff --git a/tests/FormBuilderTest.php b/tests/FormBuilderTest.php index 01354c8..d242b3d 100644 --- a/tests/FormBuilderTest.php +++ b/tests/FormBuilderTest.php @@ -171,6 +171,18 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase { } + public function testFormNumber() + { + $form1 = $this->formBuilder->number('foo'); + $form2 = $this->formBuilder->number('foo', 1); + $form3 = $this->formBuilder->number('foo', null, ['class' => 'span2']); + + $this->assertEquals('', $form1); + $this->assertEquals('', $form2); + $this->assertEquals('', $form3); + } + + public function testFormFile() { $form1 = $this->formBuilder->file('foo');