Return a proper 422 HTTP status code when the form submission fails#469
Closed
belmeopmenieuwesim wants to merge 1 commit into
Closed
Return a proper 422 HTTP status code when the form submission fails#469belmeopmenieuwesim wants to merge 1 commit into
belmeopmenieuwesim wants to merge 1 commit into
Conversation
This also brings support for Symfony UX Turbo
loic425
reviewed
Jul 28, 2022
| $parameters[$k] = $v->createView(); | ||
|
|
||
| if (200 === $response->getStatusCode() && $v->isSubmitted() && !$v->isValid()) { | ||
| $response->setStatusCode(422); |
Member
There was a problem hiding this comment.
Why not using Resonse::UNPROCESSABLE_ENTITY?
does the code you wrote come from Symfony itself?
Contributor
Author
There was a problem hiding this comment.
Yes i just copied it directly from Symfony's AbstractController.
Contributor
Author
|
Please look at this.. |
lchrusciel
added a commit
that referenced
this pull request
Oct 18, 2022
…im, Zales0123) This PR was merged into the 1.10 branch. Discussion ---------- | Q | A | --------------- | ----- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Related tickets | replaces #469 | License | MIT I\'ve taken over the #469 PR, added some tests and clean up the code. Thank you, @belmeopmenieuwesim, for the contribution 🖖 Commits ------- 1127c3d Return a proper 422 HTTP status code when the form submission fails cf06855 Test validation error code 2f3dfc2 Remove additional function for rendering the form from ControllerTrait
Contributor
|
Merged in #488 🖖 Thank you! |
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.
I noticed that the resource controller does not set the 422 http status code when a form submission fails. It is a good practice to do so. Also this will bring support for Symfony UX Turbo, which requires the status code to be set to 422 upon form failure.