-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Validation] Doesn't override properly #3224
Comments
the validation component will load the validation.xml file for every bundle (if the file exists). And each bundle can provide validation rules for the classes it wants (AcmeDemoBundle could provide rules for classes of FOSUserBundle, FrameworkBundle and AcmeHelloBundle for instance). There is no mapping between the XML file in which rules are defined and the class. |
Ok, I understand. But the problem is that the FOSUserBundle has validation setup for
My UserModel extends this class (this is necessary for FOSUserBundle to work). So in my validation.xml I want to setup my own validation rules:
But the rules of Or is the only way to create your own groups? And use them? Instead of the default FOS groups (Registration, Profile, etc) |
use different validation groups for this. it is one of their use case. |
Please post the issue in the appropriate repository: http://github.com/FriendsOfSymfony/FOSUserBundle |
@stof I tried to achieve this with validation groups, but it didn't work. |
The other thing is that groups are annoying. Just because I cannot override the validatiors in my bundle even though the documentation states I can do that!. I have to come up with a new creative validation group names which is quite annoying. |
I think this bug should be reopened. |
Can we have this reopened because creating a new groups and comming up with a proper names for them just because we cannot override the validation constraints is beyond annoying. |
What is the standard way to tell the FOSUserBundle Registration Form NOT to use the "registration" (or any other) Validation Group? I'm trying to use my own validation.xml (which I included in my bundle, but applies to the User class in the FOSUserBundle), and it works except that the error message for unique contraint for the username and email is shown twice as both the validation in my bundle (which is not in a validation group) and the validation in the FOSUserBundle, which is in the "registration" validation group, are applied. |
I don't need username for registration and my solution is: Set your own validation groups for FOSUserBundle registration and profile (eventualy for Group) form in config:
Completly redefine validations for FOSUserBundle registration with own registrations groups without username:
It works fine for me. |
@petrslavicek 👍 Thank you! |
So, I order to override validation of a 3th party bundle, that bundle needs to provide some configuration for the validation groups? Seems somewhat wrong to me... |
@wouterj You can override validation with bundle inheritance, just as described in manual. FOSUserBundle, on the other hand, gives you a possibility to override validation without the inheritance. |
@yakom you can't override it. The validation file of the parent bundle is still loaded. |
:+1 with WouterJ. All these validation group solutions seems to be a hack. |
👍 Would be really useful being able to easily override annotations. Something like
as suggested under #1021 would be really helpful. Use case for us: |
+1 Would also like to override annotations for specific installations. My use case is exactly the same as @joschi127 Will use validation groups for now. |
I'm closing this as a duplicate of #5953 which has a better problem description. |
+1 |
1 similar comment
+1 |
I want to override the FOSUserBundle validation.xml so I created a new bundle which extends the FOSUserBundle:
But the validation.xml of the FOSUserBundle is still loaded.
I think the Validation component should respect the bundle inheritance.
The text was updated successfully, but these errors were encountered: