framework: Validation error message is empty on array of file
Hi, after doing some testing, I think this is a bug.
I have this html
<input type="file" name="images[]">
<input type="file" name="images[]">
.
.
<input type="file" name="images[]">
Form Request’s rules
'images.*' => 'mimes:jpeg',
'name' => 'required',
When the file type is not jpeg, it redirects back to the input page. So the validation works, but there’s no error message. When I checked the error message bag, it is empty.
Illuminate\Support\ViewErrorBag Object ( [bags:protected] => Array ( ) )
I’m using Laravel Framework version 5.2.12
Might be related: https://github.com/laravel/framework/issues/6028
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 38 (1 by maintainers)
Potrential fix: Try replacing the
withInputmethod in theIlluminate\Http\RedirectResponseclass with the one below. I only added a return statement inside the conditional that checks if$valueis an array. This should prevent it from executing the following line and adding the array that contains the UploadedFile object to the session which causes the eventual serialization error.Update I just realized adding that return statement breaks other arrays in the form, for example, an array of text inputs. The old data for those inputs wont be added to the session. We’d need to add a bit more logic to the withInput statement or figure something else out.