Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c93974c835 | ||
|
|
501aea5374 | ||
|
|
72d6ea9713 | ||
|
|
5edfe5d8bb | ||
|
|
42a626c23e | ||
|
|
0918dac79f | ||
|
|
28a91965be | ||
|
|
f1eddc7a78 | ||
|
|
745c10226d | ||
|
|
a0a763779d | ||
|
|
c55fda58b1 | ||
|
|
8ae4aa0627 | ||
|
|
4edbd282ba | ||
|
|
3166c19203 | ||
|
|
daae1062da | ||
|
|
e4b32919a3 | ||
|
|
55eb889aca | ||
|
|
e884f50d1c | ||
|
|
52e297e679 | ||
|
|
c3a3a44a37 | ||
|
|
19860865d1 | ||
|
|
6b023d8055 |
No files matched your search
@@ -1,7 +1,6 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
|
||||
+5
-5
@@ -12,11 +12,11 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"illuminate/http": "~5.0",
|
||||
"illuminate/routing": "~5.0",
|
||||
"illuminate/session": "~5.0",
|
||||
"illuminate/support": "~5.0"
|
||||
"php": ">=5.5.9",
|
||||
"illuminate/http": "5.1.*",
|
||||
"illuminate/routing": "5.1.*",
|
||||
"illuminate/session": "5.1.*",
|
||||
"illuminate/support": "5.1.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Forms & HTML
|
||||
|
||||
[](https://travis-ci.org/LaravelCollective/html)
|
||||
[](https://packagist.org/packages/laravelcollective/html)
|
||||
[](https://packagist.org/packages/laravelcollective/html)
|
||||
[](https://packagist.org/packages/laravelcollective/html)
|
||||
[](https://packagist.org/packages/laravelcollective/html)
|
||||
[](https://packagist.org/packages/laravelcollective/html)
|
||||
|
||||
+31
-12
@@ -299,6 +299,19 @@ class FormBuilder {
|
||||
return $this->input('email', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a tel input field.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
public function tel($name, $value = null, $options = array())
|
||||
{
|
||||
return $this->input('tel', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a number input field.
|
||||
*
|
||||
@@ -330,6 +343,19 @@ class FormBuilder {
|
||||
return $this->input('date', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a time input field.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
public function time($name, $value = null, $options = array())
|
||||
{
|
||||
return $this->input('time', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a url input field.
|
||||
*
|
||||
@@ -575,7 +601,7 @@ class FormBuilder {
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $selected
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getSelectedValue($value, $selected)
|
||||
{
|
||||
@@ -908,7 +934,7 @@ class FormBuilder {
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValueAttribute($name, $value = null)
|
||||
{
|
||||
@@ -931,25 +957,18 @@ class FormBuilder {
|
||||
* Get the model value that should be assigned to the field.
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getModelValueAttribute($name)
|
||||
{
|
||||
if (is_object($this->model))
|
||||
{
|
||||
return object_get($this->model, $this->transformKey($name));
|
||||
}
|
||||
elseif (is_array($this->model))
|
||||
{
|
||||
return array_get($this->model, $this->transformKey($name));
|
||||
}
|
||||
return data_get($this->model, $this->transformKey($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value from the session's old input.
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
public function old($name)
|
||||
{
|
||||
|
||||
+22
-3
@@ -96,6 +96,25 @@ class HtmlBuilder {
|
||||
|
||||
return '<img src="'.$this->url->asset($url, $secure).'"'.$this->attributes($attributes).'>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a link to a Favicon file.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $attributes
|
||||
* @param bool $secure
|
||||
* @return string
|
||||
*/
|
||||
public function favicon($url, $attributes = array(), $secure = null)
|
||||
{
|
||||
$defaults = array('rel' => 'shortcut icon', 'type' => 'image/x-icon');
|
||||
|
||||
$attributes = $attributes + $defaults;
|
||||
|
||||
$attributes['href'] = $this->url->asset($url, $secure);
|
||||
|
||||
return '<link'.$this->attributes($attributes).'>'.PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a HTML link.
|
||||
@@ -339,9 +358,6 @@ class HtmlBuilder {
|
||||
{
|
||||
$html = array();
|
||||
|
||||
// For numeric keys we will assume that the key and the value are the same
|
||||
// as this will convert HTML attributes such as "required" to a correct
|
||||
// form like required="required" instead of using incorrect numerics.
|
||||
foreach ((array) $attributes as $key => $value)
|
||||
{
|
||||
$element = $this->attributeElement($key, $value);
|
||||
@@ -361,6 +377,9 @@ class HtmlBuilder {
|
||||
*/
|
||||
protected function attributeElement($key, $value)
|
||||
{
|
||||
// For numeric keys we will assume that the key and the value are the same
|
||||
// as this will convert HTML attributes such as "required" to a correct
|
||||
// form like required="required" instead of using incorrect numerics.
|
||||
if (is_numeric($key)) $key = $value;
|
||||
|
||||
if ( ! is_null($value)) return $key.'="'.e($value).'"';
|
||||
|
||||
@@ -61,7 +61,7 @@ class HtmlServiceProvider extends ServiceProvider {
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return array('html', 'form');
|
||||
return array('html', 'form', 'Collective\Html\HtmlBuilder', 'Collective\Html\FormBuilder');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -137,6 +137,18 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
|
||||
public function testFormRepopulationWithMixOfArraysAndObjects()
|
||||
{
|
||||
$this->formBuilder->model(['user' => (object)['password' => 'apple']]);
|
||||
$input = $this->formBuilder->text('user[password]');
|
||||
$this->assertEquals('<input name="user[password]" type="text" value="apple">', $input);
|
||||
|
||||
$this->formBuilder->model((object)['letters' => ['a', 'b', 'c']]);
|
||||
$input = $this->formBuilder->text('letters[1]');
|
||||
$this->assertEquals('<input name="letters[1]" type="text" value="b">', $input);
|
||||
}
|
||||
|
||||
|
||||
public function testFormPassword()
|
||||
{
|
||||
$form1 = $this->formBuilder->password('foo');
|
||||
@@ -171,6 +183,18 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
|
||||
public function testFormTel()
|
||||
{
|
||||
$form1 = $this->formBuilder->tel('foo');
|
||||
$form2 = $this->formBuilder->tel('foo', 'foobar');
|
||||
$form3 = $this->formBuilder->tel('foo', null, ['class' => 'span2']);
|
||||
|
||||
$this->assertEquals('<input name="foo" type="tel">', $form1);
|
||||
$this->assertEquals('<input name="foo" type="tel" value="foobar">', $form2);
|
||||
$this->assertEquals('<input class="span2" name="foo" type="tel">', $form3);
|
||||
}
|
||||
|
||||
|
||||
public function testFormNumber()
|
||||
{
|
||||
$form1 = $this->formBuilder->number('foo');
|
||||
@@ -195,6 +219,17 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
||||
$this->assertEquals('<input class="span2" name="foo" type="date">', $form4);
|
||||
}
|
||||
|
||||
public function testFormTime()
|
||||
{
|
||||
$form1 = $this->formBuilder->time('foo');
|
||||
$form2 = $this->formBuilder->time('foo', \Carbon\Carbon::now()->format('H:i'));
|
||||
$form3 = $this->formBuilder->time('foo', null, ['class' => 'span2']);
|
||||
|
||||
$this->assertEquals('<input name="foo" type="time">', $form1);
|
||||
$this->assertEquals('<input name="foo" type="time" value="' . \Carbon\Carbon::now()->format('H:i') . '">', $form2);
|
||||
$this->assertEquals('<input class="span2" name="foo" type="time">', $form3);
|
||||
}
|
||||
|
||||
|
||||
public function testFormFile()
|
||||
{
|
||||
@@ -462,4 +497,4 @@ class FormBuilderModelStub {
|
||||
{
|
||||
return isset($this->data[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,4 +55,13 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase {
|
||||
$this->assertEquals('<meta content="website" property="og:type">'.PHP_EOL, $result);
|
||||
}
|
||||
|
||||
}
|
||||
public function testFavicon()
|
||||
{
|
||||
$this->urlGenerator->forceRootUrl('http://foo.com');
|
||||
$target = $this->urlGenerator->to('bar.ico');
|
||||
$result = $this->htmlBuilder->favicon('http://foo.com/bar.ico');
|
||||
|
||||
$this->assertEquals('<link rel="shortcut icon" type="image/x-icon" href="'.$target.'">' . PHP_EOL, $result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user