Compare commits

...
2 Commits
Author SHA1 Message Date
Anderson Friaça 41cd9291a6 [5.6] Validation in select field for boolean value of selected option (#491) 2018-02-12 06:19:42 -08:00
Tortue Torche 818efc2e16 [5.6] Form method of hidden input '_method' is preserved on next request (#486)
* Form method of hidden input '_method' is preserved on next request

E.G. When you submitted data across a form with a 'PATCH' method and then in a second submit you use a form with a 'DELETE' method, the FormBuilder::getValueAttribute() method use the previous value of the hidden input '_method'.
So the value is replaced by 'PATCH' instead of the 'DELETE' value.

* Drop PHP 7.1 and add PHP 7.2 in Travis CI config

Because Laravel 5.6 require at least PHP 7.1.3

* Fix PHP 7.2 Warning with count()

Otherwise a PHP Warning is thrown:
count(): Parameter must be an array or an object that implements Countable

See http://php.net/manual/en/migration72.incompatible.php#migration72.incompatible.warn-on-non-countable-types

* Bump Mockery version to support PHP 7.2
2018-02-08 10:38:44 -08:00
4 changed files with 14 additions and 5 deletions

No files matched your search

+1
View File
@@ -2,6 +2,7 @@ language: php
php:
- 7.1
- 7.2
sudo: false
+1 -1
View File
@@ -27,7 +27,7 @@
},
"require-dev": {
"illuminate/database": "5.6.*",
"mockery/mockery": "~0.9.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~5.4"
},
"autoload": {
+6 -4
View File
@@ -572,7 +572,7 @@ class FormBuilder
*
* @param string $name
* @param array $list
* @param string $selected
* @param string|bool $selected
* @param array $selectAttributes
* @param array $optionsAttributes
* @param array $optgroupsAttributes
@@ -787,7 +787,9 @@ class FormBuilder
} elseif ($selected instanceof Collection) {
return $selected->contains($value) ? 'selected' : null;
}
if (is_int($value) && is_bool($selected)) {
return (bool)$value === $selected;
}
return ((string) $value === (string) $selected) ? 'selected' : null;
}
@@ -1184,7 +1186,7 @@ class FormBuilder
}
$request = $this->request($name);
if (! is_null($request)) {
if (! is_null($request) && $name != '_method') {
return $request;
}
@@ -1268,7 +1270,7 @@ class FormBuilder
*/
public function oldInputIsEmpty()
{
return (isset($this->session) && count($this->session->getOldInput()) === 0);
return (isset($this->session) && count((array) $this->session->getOldInput()) === 0);
}
/**
+6
View File
@@ -464,6 +464,12 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
'<select name="countries"><option value="1" selected="selected">L</option><option value="2">M</option></select>',
$result
);
$select = $this->formBuilder->select('avc', [1 => 'Yes', 0 => 'No'], true, ['placeholder' => 'Select']);
$this->assertEquals(
'<select name="avc"><option value="" hidden="hidden">Select</option><option value="1" selected>Yes</option><option value="0" >No</option></select>',
$select
);
}
public function testSelectCollection()