Replacing/Merging inside FormRequest passedValidation doesn't work as intended. #57723
Replies: 4 comments
-
|
Testing other methods, I found out that |
Beta Was this translation helpful? Give feedback.
-
|
We noticed the replace is not working globally ok so we bypassed it with a macro Request::macro('forceReplace', function (array $data): Request {
/** @var Request $this */
$this->query->replace();
$this->request->replace();
$this->replace($data);
return $this;
}); |
Beta Was this translation helpful? Give feedback.
-
|
I've created a fix for this issue in PR #57666. The problem was that when The fix syncs the validator's data with the current request data after |
Beta Was this translation helpful? Give feedback.
-
Thank you @mosabbirrakib for solving the issue. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
12.36.1
PHP Version
8.4.13
Database Driver & Version
No database
Description
Inside the
FormRequestinstance, using$this->replace([])does not work as intended.The return value from
$request->validated()in the controller is different from what is expected.Instead, the data remains exactly the same as before calling
passedValidation().This behavior doesn't affect
prepareForValidation().Steps To Reproduce
https://github.com/JesterIruka/laravel-passed-validation-bug
Edit: run php artisan test
Beta Was this translation helpful? Give feedback.
All reactions