New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate uploadIniSizeError if entity form is nested in the form of another entity #36503
Comments
Could it be the same issue as #32045? |
Thank you for your feedback! Yes and no. I have not encountered this issue with nonnested forms. Furthermore, in my case all errors are properly translated. |
As i see there two messages because you got one message with the |
I believe it is the expected behaviour, it does seem to work like that if the FormType with a file input is not nested in another FormType. |
Can you please check if #39119 fixes this? |
…mits (xabbuh) This PR was merged into the 4.4 branch. Discussion ---------- [Form] prevent duplicated error message for file upload limits | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #32045, #36503, #39107 | License | MIT | Doc PR | Commits ------- fe6a2dd prevent duplicated error message for file upload limits
Symfony version(s) affected: 4.4.7
Description
Error based on php.ini
upload_max_filesize
is thrown two time if the file entity form is nested in the form of another entity (e.g. aCompany
and aLogo
entities) AND the file entity itself has aFile
orImage
constraint.Steps to reproduce
You can download the "bug reproducer" here: https://github.com/thibaut-decherit/nested-file-entity-bug
Make sure you have
upload_max_filesize = 2M
in yourphp.ini
.Go to
localhost:8000/new
and submit an image larger than 2Mo.Two errors should appear instead of one.
Assumption
It's like the file size is validated prior to
@Assert\Image()
insrc/Entity/Logo.php
(maybe by the form itself or indirectly through a caught exception?) then a second time by@Assert\Image()
, this time properly overwritten bymaxSize="2M"
(note the[...] size is 2 MB
instead of[...] size is 2 MiB
):Note that if you remove
@Assert\Valid()
fromsrc/Entity/Company.php
only the first error is thrown:(but
@Assert\Image()
is ignored so it is not a solution, you can confirm this by trying to submit a file other than jpeg, you will not get an error)The text was updated successfully, but these errors were encountered: