-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Symfony 3.2 isValid always return false #20805
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
Comments
Hi @dominikzogg, you should read the 3.2 upgrade file and call: if ($form->isSubmitted() && false === $form->isValid()) {
....
} Does it solve your issue? |
@HeahDude no it does not, i saw within sample, but as you can see within submit() $this->submitted = true; will always be set |
doing it this way works perfect, which tells me validation works |
Hmm, looks weird. Could you please fork symfony standard and add at the minimum of code to reproduce this? Thanks! |
you shouldn't use submit, which seems to be the problem. this is how i do it on my systems: $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
} use this to get the Request: public function myAction(Request $request) {
} |
@Hanmac handleRequest is bad for api, cause the missing second argument which allows to ignore not send values |
@HeahDude i can live with duplicate validation for the moment, can't spend the time to strip down this project (big, closed source onces). |
@dominikzogg can you please try the patch from #20966, to see if this about a transformation failure? Another possibility is that using |
@dominikzogg I am closing here for now as we cannot solve the issue without a reproducable example. However, I will happily reopen once we have such a fork of the Symfony Standard Edition. |
Can you confirm that the changes proposed in #30265 will fix this issue? |
…requests (xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- [Form] do not validate non-submitted form fields in PATCH requests | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11493, #19788, #20805, #24453, #30011 | License | MIT | Doc PR | When a form field is not embedded as part of a HTTP PATCH requests, its validation constraints configured through the `constraints` option must not be evaluated. The fix from #10567 achieved this by not mapping their violations to the underlying form field. This however also means that constraint violations caused by validating the whole underlying data object will never cause the form to be invalid. This breaks use cases where some constraints may, for example, depend on the value of other properties that were changed by the submitted data. Commits ------- a60d802 do not validate non-submitted form fields in PATCH requests
the following code worked within symfony 2.8 (patch action), after updating to symfony 3.2 i always get into the if statement, even if there are no errors. calling the validator myself, would tell everything is fine.
Do i missed a change, that does not throw an exception, but ends in this strange behavior?
I already refactored the createForm to:
The text was updated successfully, but these errors were encountered: