Repository navigation
[6.x] Fix form submissions with an empty upload field that has file size rules - #16026
Open
el-schneider wants to merge 1 commit into
Open
el-schneider wants to merge 1 commit into
el-schneider wants to merge 1 commit into
Conversation
el-schneider
marked this pull request as ready for review
November 24, 2026 20:39
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a form has an
assets,filesoruploadfield with a file size rule likemax_filesize, and the field is left empty, the submission throws:These fieldtypes turn their file rules into rule objects in
fieldRules()(MaxRule,MinRule,ImageRuleand so on). For an upload field that didn't receive a new file,SubmitForm::withFileUploadRules()drops thearray,max:andmin:rules, and it passes every rule tostr_starts_with()to find them, including the objects.This PR only checks string rules there and leaves the rule objects in place. Laravel doesn't run them against an empty value, so an empty optional field passes validation again, like it did before #15039.
To reproduce, add an optional
filesfield withvalidate: ['max_filesize:1024']to a form and submit it without picking a file.Going back to a page that already has a stored upload and resubmitting it still runs the file size rules against the stored value, and they fail there. Which rules should apply to carried-over values felt like a separate decision, so I left it out of this PR.
Regression from #15039.