Compare commits

..
11 Commits
4 changed files with 26 additions and 32 deletions

No files matched your search

+1
View File
@@ -1,6 +1,7 @@
language: php language: php
php: php:
- 5.6
- 7.0 - 7.0
- 7.1 - 7.1
+7 -23
View File
@@ -18,15 +18,15 @@
} }
], ],
"require": { "require": {
"php": ">=7.0.0", "php": ">=5.6.4",
"illuminate/http": "5.5.*", "illuminate/http": "5.4.*",
"illuminate/routing": "5.5.*", "illuminate/routing": "5.4.*",
"illuminate/session": "5.5.*", "illuminate/session": "5.4.*",
"illuminate/support": "5.5.*", "illuminate/support": "5.4.*",
"illuminate/view": "5.5.*" "illuminate/view": "5.4.*"
}, },
"require-dev": { "require-dev": {
"illuminate/database": "5.5.*", "illuminate/database": "5.4.*",
"mockery/mockery": "~0.9.4", "mockery/mockery": "~0.9.4",
"phpunit/phpunit": "~5.4" "phpunit/phpunit": "~5.4"
}, },
@@ -37,21 +37,5 @@
"files": [ "files": [
"src/helpers.php" "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
View File
@@ -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);
+15 -3
View File
@@ -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 &nbsp;'] ['placeholder' => 'Select the &nbsp;']
); );
$this->assertEquals($select, $this->assertEquals($select,
'<select name="encoded_html"><option selected="selected" disabled="disabled" hidden="hidden" value="">Select the &nbsp;</option><option value="no_break_space">&nbsp;</option><option value="ampersand">&amp;</option><option value="lower_than">&lt;</option></select>' '<select name="encoded_html"><option selected="selected" value="">Select the &nbsp;</option><option value="no_break_space">&nbsp;</option><option value="ampersand">&amp;</option><option value="lower_than">&lt;</option></select>'
); );
} }