-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Attatching an AbstractComparisonValidator to FormType contains the Form object and throws exception #28987
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
Setting a constraint via the form builder is not the same as setting a constraint on the data object. Not sure if this is a bug, but their behavior is different. |
Thanks for reporting this @gmponos. I will investigate on this, but to quickly fix your problem the workaround is to use the property path |
@HeahDude thanks in advance. If this should behave differently then I will submit a PR to docs suggesting a notice about this and the work around you mention. For me I believe that constraints should behave the same regardless if they are defined through yaml/annotation/php/form. |
This looks expected to me. When using the |
I am closing as explained |
Hello, My explanation was wrong
Basically if I attach a constraint to the field I have only the field visible so if I do something like this:
I get the following error:
If I add the constraint to the form I do not have access to both parts of the comparison
|
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 4.1.x
Description
When I attach to an object of mine through Yaml or annotation one of the
EqualsTo/NotEqualsTo/IdenticalTo/NotIdenticalTo
constraints then this line returns the object that the constraint is attached to.So the line above will return the object
App\Form\Transfer
If I add the constraint on a form type like this:
The line above will bring back a form object.
This causes the constraint to throw an exception because it reaches on this line and in the Form object the path of the property it does not exist.
How to reproduce
Build a form in the way described above and submit it.
The text was updated successfully, but these errors were encountered: