Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f04965dc68 | ||
|
|
c33e621a49 | ||
|
|
f905913a3a | ||
|
|
8c8cea0c3b | ||
|
|
1ceed988c6 | ||
|
|
a96da91fb9 | ||
|
|
0c1a869f4c | ||
|
|
0140f72370 | ||
|
|
6288505bbb | ||
|
|
9b8f51e7a2 | ||
|
|
5e0ef251d4 |
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
|
- 5.6
|
||||||
- 7.0
|
- 7.0
|
||||||
- 7.1
|
- 7.1
|
||||||
|
|
||||||
|
|||||||
+37
-53
@@ -1,57 +1,41 @@
|
|||||||
{
|
{
|
||||||
"name": "laravelcollective/html",
|
"name": "laravelcollective/html",
|
||||||
"description": "HTML and Form Builders for the Laravel Framework",
|
"description": "HTML and Form Builders for the Laravel Framework",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "http://laravelcollective.com",
|
"homepage": "http://laravelcollective.com",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/LaravelCollective/html/issues",
|
"issues": "https://github.com/LaravelCollective/html/issues",
|
||||||
"source": "https://github.com/LaravelCollective/html"
|
"source": "https://github.com/LaravelCollective/html"
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Adam Engebretson",
|
||||||
|
"email": "adam@laravelcollective.com"
|
||||||
},
|
},
|
||||||
"authors": [
|
{
|
||||||
{
|
"name": "Taylor Otwell",
|
||||||
"name": "Adam Engebretson",
|
"email": "taylorotwell@gmail.com"
|
||||||
"email": "adam@laravelcollective.com"
|
}
|
||||||
},
|
],
|
||||||
{
|
"require": {
|
||||||
"name": "Taylor Otwell",
|
"php": ">=5.6.4",
|
||||||
"email": "taylorotwell@gmail.com"
|
"illuminate/http": "5.4.*",
|
||||||
}
|
"illuminate/routing": "5.4.*",
|
||||||
],
|
"illuminate/session": "5.4.*",
|
||||||
"require": {
|
"illuminate/support": "5.4.*",
|
||||||
"php": ">=7.0.0",
|
"illuminate/view": "5.4.*"
|
||||||
"illuminate/http": "5.5.*",
|
},
|
||||||
"illuminate/routing": "5.5.*",
|
"require-dev": {
|
||||||
"illuminate/session": "5.5.*",
|
"illuminate/database": "5.4.*",
|
||||||
"illuminate/support": "5.5.*",
|
"mockery/mockery": "~0.9.4",
|
||||||
"illuminate/view": "5.5.*"
|
"phpunit/phpunit": "~5.4"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Collective\\Html\\": "src/"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"files": [
|
||||||
"illuminate/database": "5.5.*",
|
"src/helpers.php"
|
||||||
"mockery/mockery": "~0.9.4",
|
]
|
||||||
"phpunit/phpunit": "~5.4"
|
}
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Collective\\Html\\": "src/"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"src/helpers.php"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "5.5-dev"
|
|
||||||
},
|
|
||||||
"laravel": {
|
|
||||||
"providers": [
|
|
||||||
"Collective\\Html\\HtmlServiceProvider"
|
|
||||||
],
|
|
||||||
"aliases": {
|
|
||||||
"Form": "Collective\\Html\\FormFacade",
|
|
||||||
"Html": "Collective\\Html\\HtmlFacade"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"minimum-stability": "dev",
|
|
||||||
"prefer-stable": true
|
|
||||||
}
|
}
|
||||||
+3
-6
@@ -741,9 +741,7 @@ class FormBuilder
|
|||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
'selected' => $selected,
|
'selected' => $selected,
|
||||||
'disabled' => 'disabled',
|
'value' => '',
|
||||||
'hidden' => 'hidden',
|
|
||||||
'value' => ''
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
||||||
@@ -760,7 +758,7 @@ class FormBuilder
|
|||||||
protected function getSelectedValue($value, $selected)
|
protected function getSelectedValue($value, $selected)
|
||||||
{
|
{
|
||||||
if (is_array($selected)) {
|
if (is_array($selected)) {
|
||||||
return in_array($value, $selected, true) ? 'selected' : null;
|
return in_array($value, $selected, true) || in_array((string) $value, $selected, true) ? 'selected' : null;
|
||||||
} elseif ($selected instanceof Collection) {
|
} elseif ($selected instanceof Collection) {
|
||||||
return $selected->contains($value) ? 'selected' : null;
|
return $selected->contains($value) ? 'selected' : null;
|
||||||
}
|
}
|
||||||
@@ -1192,11 +1190,10 @@ 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
|
||||||
* @param mixed $model
|
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function getModelValueAttribute($name, $model = null)
|
protected function getModelValueAttribute($name)
|
||||||
{
|
{
|
||||||
$key = $this->transformKey($name);
|
$key = $this->transformKey($name);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use Illuminate\Routing\RouteCollection;
|
|||||||
use Illuminate\Routing\UrlGenerator;
|
use Illuminate\Routing\UrlGenerator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Session\Store;
|
||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
|
|
||||||
class FormBuilderTest extends PHPUnit_Framework_TestCase
|
class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||||
@@ -421,6 +422,17 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
$this->assertEquals($select,
|
$this->assertEquals($select,
|
||||||
'<select name="size"><option value="L" data-foo="bar" disabled>Large</option><option value="S">Small</option></select>');
|
'<select name="size"><option value="L" data-foo="bar" disabled>Large</option><option value="S">Small</option></select>');
|
||||||
|
|
||||||
|
$store = new Store('name', new \SessionHandler());
|
||||||
|
$store->put('_old_input', ['countries' => ['1']]);
|
||||||
|
$this->formBuilder->setSessionStore($store);
|
||||||
|
|
||||||
|
$result = $this->formBuilder->select('countries', [1 => 'L', 2 => 'M']);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
'<select name="countries"><option value="1" selected="selected">L</option><option value="2">M</option></select>',
|
||||||
|
$result
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSelectCollection()
|
public function testSelectCollection()
|
||||||
@@ -467,7 +479,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
['placeholder' => 'Select One...']
|
['placeholder' => 'Select One...']
|
||||||
);
|
);
|
||||||
$this->assertEquals($select,
|
$this->assertEquals($select,
|
||||||
'<select name="size"><option selected="selected" disabled="disabled" hidden="hidden" value="">Select One...</option><option value="L">Large</option><option value="S">Small</option></select>');
|
'<select name="size"><option selected="selected" value="">Select One...</option><option value="L">Large</option><option value="S">Small</option></select>');
|
||||||
|
|
||||||
$select = $this->formBuilder->select(
|
$select = $this->formBuilder->select(
|
||||||
'size',
|
'size',
|
||||||
@@ -476,7 +488,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
['placeholder' => 'Select One...']
|
['placeholder' => 'Select One...']
|
||||||
);
|
);
|
||||||
$this->assertEquals($select,
|
$this->assertEquals($select,
|
||||||
'<select name="size"><option disabled="disabled" hidden="hidden" value="">Select One...</option><option value="L" selected="selected">Large</option><option value="S">Small</option></select>');
|
'<select name="size"><option value="">Select One...</option><option value="L" selected="selected">Large</option><option value="S">Small</option></select>');
|
||||||
|
|
||||||
$select = $this->formBuilder->select(
|
$select = $this->formBuilder->select(
|
||||||
'encoded_html',
|
'encoded_html',
|
||||||
@@ -485,7 +497,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
['placeholder' => 'Select the ']
|
['placeholder' => 'Select the ']
|
||||||
);
|
);
|
||||||
$this->assertEquals($select,
|
$this->assertEquals($select,
|
||||||
'<select name="encoded_html"><option selected="selected" disabled="disabled" hidden="hidden" value="">Select the </option><option value="no_break_space"> </option><option value="ampersand">&</option><option value="lower_than"><</option></select>'
|
'<select name="encoded_html"><option selected="selected" value="">Select the </option><option value="no_break_space"> </option><option value="ampersand">&</option><option value="lower_than"><</option></select>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user