Compare commits

...
17 Commits
Author SHA1 Message Date
Adam Engebretson 0918dac79f Removing PHP 5.4
Signed-off-by: Adam Engebretson <adam@enge.me>
2015-06-17 21:16:50 -05:00
Adam Engebretson 28a91965be Tagging 5.1 stable
Signed-off-by: Adam Engebretson <adam@enge.me>
2015-06-17 21:13:55 -05:00
Adam Engebretson f1eddc7a78 Updating Illuminate Depends
Signed-off-by: Adam Engebretson <adam@enge.me>
2015-05-21 11:45:14 -05:00
Adam Engebretson 745c10226d Adding branch alias
Signed-off-by: Adam Engebretson <adam@enge.me>
2015-05-21 11:44:56 -05:00
Tom a0a763779d Merge pull request #33 from garygreen/fix-model-bindings
Fix model form-binding with array with objects and object with arrays.
2015-05-06 08:48:56 -07:00
Tom c55fda58b1 Merge pull request #22 from JosephSilber/patch-2
Move comment to correct spot
2015-05-06 07:23:37 -07:00
Tom 8ae4aa0627 Merge pull request #30 from barryvdh/patch-1
Add aliases to provides()
2015-05-06 07:22:33 -07:00
Tom 4edbd282ba Merge pull request #26 from toniperic/patch-1
Add support for Favicon files
2015-05-06 07:18:34 -07:00
Tom 3166c19203 Merge pull request #34 from garygreen/fix-docblocks
Fix some docblock returns
2015-05-06 07:17:50 -07:00
Gary daae1062da Fix some docblock returns 2015-04-25 13:19:56 +01:00
Gary e4b32919a3 Fix model form-binding with array with objects and object with arrays. 2015-04-25 13:14:08 +01:00
Tom 55eb889aca Update readme.md 2015-04-23 07:38:50 -07:00
Barry vd. Heuvel e884f50d1c Add aliases to provides() 2015-04-17 08:56:47 +02:00
Toni Perić 52e297e679 Newline at the end of the file 2015-04-07 22:06:26 +02:00
Toni Perić c3a3a44a37 Added test 2015-04-07 21:43:57 +02:00
Toni Perić 19860865d1 Update HtmlBuilder.php
Add support for Favicon files.
2015-04-07 20:45:59 +02:00
Joseph Silber 6b023d8055 Move comment to correct spot 2015-03-29 18:06:56 -04:00
8 changed files with 55 additions and 23 deletions

No files matched your search

-1
View File
@@ -1,7 +1,6 @@
language: php language: php
php: php:
- 5.4
- 5.5 - 5.5
- 5.6 - 5.6
- hhvm - hhvm
+5 -5
View File
@@ -12,11 +12,11 @@
} }
], ],
"require": { "require": {
"php": ">=5.4.0", "php": ">=5.5.9",
"illuminate/http": "~5.0", "illuminate/http": "5.1.*",
"illuminate/routing": "~5.0", "illuminate/routing": "5.1.*",
"illuminate/session": "~5.0", "illuminate/session": "5.1.*",
"illuminate/support": "~5.0" "illuminate/support": "5.1.*"
}, },
"require-dev": { "require-dev": {
"mockery/mockery": "~0.9", "mockery/mockery": "~0.9",
+1 -1
View File
@@ -1,7 +1,7 @@
# Forms & HTML # Forms & HTML
[![Build Status](https://travis-ci.org/LaravelCollective/html.svg)](https://travis-ci.org/LaravelCollective/html) [![Build Status](https://travis-ci.org/LaravelCollective/html.svg)](https://travis-ci.org/LaravelCollective/html)
[![Total Downloads](https://poser.pugx.org/LaravelCollective/html/downloads.svg)](https://packagist.org/packages/laravelcollective/html) [![Total Downloads](https://poser.pugx.org/LaravelCollective/html/downloads)](https://packagist.org/packages/laravelcollective/html)
[![Latest Stable Version](https://poser.pugx.org/LaravelCollective/html/v/stable.svg)](https://packagist.org/packages/laravelcollective/html) [![Latest Stable Version](https://poser.pugx.org/LaravelCollective/html/v/stable.svg)](https://packagist.org/packages/laravelcollective/html)
[![Latest Unstable Version](https://poser.pugx.org/LaravelCollective/html/v/unstable.svg)](https://packagist.org/packages/laravelcollective/html) [![Latest Unstable Version](https://poser.pugx.org/LaravelCollective/html/v/unstable.svg)](https://packagist.org/packages/laravelcollective/html)
[![License](https://poser.pugx.org/LaravelCollective/html/license.svg)](https://packagist.org/packages/laravelcollective/html) [![License](https://poser.pugx.org/LaravelCollective/html/license.svg)](https://packagist.org/packages/laravelcollective/html)
+5 -12
View File
@@ -575,7 +575,7 @@ class FormBuilder {
* *
* @param string $value * @param string $value
* @param string $selected * @param string $selected
* @return string * @return string|null
*/ */
protected function getSelectedValue($value, $selected) protected function getSelectedValue($value, $selected)
{ {
@@ -908,7 +908,7 @@ class FormBuilder {
* *
* @param string $name * @param string $name
* @param string $value * @param string $value
* @return string * @return mixed
*/ */
public function getValueAttribute($name, $value = null) public function getValueAttribute($name, $value = null)
{ {
@@ -931,25 +931,18 @@ class FormBuilder {
* Get the model value that should be assigned to the field. * Get the model value that should be assigned to the field.
* *
* @param string $name * @param string $name
* @return string * @return mixed
*/ */
protected function getModelValueAttribute($name) protected function getModelValueAttribute($name)
{ {
if (is_object($this->model)) return data_get($this->model, $this->transformKey($name));
{
return object_get($this->model, $this->transformKey($name));
}
elseif (is_array($this->model))
{
return array_get($this->model, $this->transformKey($name));
}
} }
/** /**
* Get a value from the session's old input. * Get a value from the session's old input.
* *
* @param string $name * @param string $name
* @return string * @return mixed
*/ */
public function old($name) public function old($name)
{ {
+22 -3
View File
@@ -97,6 +97,25 @@ class HtmlBuilder {
return '<img src="'.$this->url->asset($url, $secure).'"'.$this->attributes($attributes).'>'; 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. * Generate a HTML link.
* *
@@ -339,9 +358,6 @@ class HtmlBuilder {
{ {
$html = array(); $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) foreach ((array) $attributes as $key => $value)
{ {
$element = $this->attributeElement($key, $value); $element = $this->attributeElement($key, $value);
@@ -361,6 +377,9 @@ class HtmlBuilder {
*/ */
protected function attributeElement($key, $value) 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_numeric($key)) $key = $value;
if ( ! is_null($value)) return $key.'="'.e($value).'"'; if ( ! is_null($value)) return $key.'="'.e($value).'"';
+1 -1
View File
@@ -61,7 +61,7 @@ class HtmlServiceProvider extends ServiceProvider {
*/ */
public function provides() public function provides()
{ {
return array('html', 'form'); return array('html', 'form', 'Collective\Html\HtmlBuilder', 'Collective\Html\FormBuilder');
} }
} }
+12
View File
@@ -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() public function testFormPassword()
{ {
$form1 = $this->formBuilder->password('foo'); $form1 = $this->formBuilder->password('foo');
+9
View File
@@ -55,4 +55,13 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('<meta content="website" property="og:type">'.PHP_EOL, $result); $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);
}
} }