Skip to content

Commit c93974c

Browse files
committed
Merge pull request #58 from kirkaracha/5.1
Added tel input type and test
2 parents 72d6ea9 + 501aea5 commit c93974c

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/FormBuilder.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,19 @@ public function email($name, $value = null, $options = array())
299299
return $this->input('email', $name, $value, $options);
300300
}
301301

302+
/**
303+
* Create a tel input field.
304+
*
305+
* @param string $name
306+
* @param string $value
307+
* @param array $options
308+
* @return string
309+
*/
310+
public function tel($name, $value = null, $options = array())
311+
{
312+
return $this->input('tel', $name, $value, $options);
313+
}
314+
302315
/**
303316
* Create a number input field.
304317
*
@@ -329,7 +342,7 @@ public function date($name, $value = null, $options = array())
329342

330343
return $this->input('date', $name, $value, $options);
331344
}
332-
345+
333346
/**
334347
* Create a time input field.
335348
*

tests/FormBuilderTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,18 @@ public function testFormEmail()
183183
}
184184

185185

186+
public function testFormTel()
187+
{
188+
$form1 = $this->formBuilder->tel('foo');
189+
$form2 = $this->formBuilder->tel('foo', 'foobar');
190+
$form3 = $this->formBuilder->tel('foo', null, ['class' => 'span2']);
191+
192+
$this->assertEquals('<input name="foo" type="tel">', $form1);
193+
$this->assertEquals('<input name="foo" type="tel" value="foobar">', $form2);
194+
$this->assertEquals('<input class="span2" name="foo" type="tel">', $form3);
195+
}
196+
197+
186198
public function testFormNumber()
187199
{
188200
$form1 = $this->formBuilder->number('foo');
@@ -217,8 +229,8 @@ public function testFormTime()
217229
$this->assertEquals('<input name="foo" type="time" value="' . \Carbon\Carbon::now()->format('H:i') . '">', $form2);
218230
$this->assertEquals('<input class="span2" name="foo" type="time">', $form3);
219231
}
220-
221-
232+
233+
222234
public function testFormFile()
223235
{
224236
$form1 = $this->formBuilder->file('foo');

0 commit comments

Comments
 (0)