Skip to content

Commit

Permalink
[5.6] Form method of hidden input '_method' is preserved on next requ…
Browse files Browse the repository at this point in the history
…est (#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
  • Loading branch information
tortuetorche authored and tshafer committed Feb 8, 2018
1 parent e649632 commit 818efc2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: php

php:
- 7.1
- 7.2

sudo: false

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"require-dev": {
"illuminate/database": "5.6.*",
"mockery/mockery": "~0.9.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~5.4"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions src/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ public function getValueAttribute($name, $value = null)
}

$request = $this->request($name);
if (! is_null($request)) {
if (! is_null($request) && $name != '_method') {
return $request;
}

Expand Down Expand Up @@ -1268,7 +1268,7 @@ public function old($name)
*/
public function oldInputIsEmpty()
{
return (isset($this->session) && count($this->session->getOldInput()) === 0);
return (isset($this->session) && count((array) $this->session->getOldInput()) === 0);
}

/**
Expand Down

0 comments on commit 818efc2

Please sign in to comment.