Skip to content
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

ViolationMapper problem with acceptsErrors for not submitted values #24453

Closed
kalinick opened this issue Oct 6, 2017 · 5 comments
Closed

ViolationMapper problem with acceptsErrors for not submitted values #24453

kalinick opened this issue Oct 6, 2017 · 5 comments

Comments

@kalinick
Copy link

kalinick commented Oct 6, 2017

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version 3.3.9

I have the problem with ViolationMapper. It skip values that was not submitted. The problem appear in validation groups. If field is not submitted, but mentioned in validation group. Validator found constraint, but form not map it.

It can be solved by object direct validation. But here appear problem how combine form errors and object. Also i should validate object twice.

Can in method acceptsErrors, $form->isSubmitted() check be optional? Or ViolationMapper added to FormTypeValidatorExtension as service

@xabbuh
Copy link
Member

xabbuh commented Oct 6, 2017

Can you create a small example project that illustrates your problem? I am not sure if I really understood it.

@kalinick
Copy link
Author

kalinick commented Oct 6, 2017

It looks like responsibility of form is to test only form values. But it validate entity anyway. So it will be cool to have mechanizm to get from form full entity validation (not only form)

@hbouhadji-vp
Copy link

Did you found a solution to this issue since ? Thx @kalinick

@xabbuh
Copy link
Member

xabbuh commented Feb 15, 2019

Can you confirm that the changes proposed in #30265 will fix this issue?

xabbuh added a commit that referenced this issue Feb 21, 2019
…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
@xabbuh xabbuh closed this as completed Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants