Fosuserbundle registration form confirmation

I am using FOSUserBundle. In my project, I created my own UserBundle and reconfigured the controller, forms, and handlers. Now, when a user tries to register with an existing email, the site crashes (email is unique to the doctrine). Validation does not seem to be done. I thought there would be some kind of check, as in my validation.yml:

YOP\UserBundle\Entity\User: constraints: - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: email properties: email: - Email: ~ 

Why is verification not performed in the email field? How can I make sure my validation restrictions are taken into account?

PS: validation.yml file is not in my UserBundle, is this a problem?

EDIT:

The code of my UserBundle is available here. I don’t understand why the check is no longer performed ...

+1
validation symfony fosuserbundle
Sep 05 '12 at 7:16
source share
2 answers

Solution:

  • having a validation.yml file in the same package as the one that contains my User object and pointing to my user object
  • adding the "Registration" check group to my fields

validation.yml:

 YOP\YourOwnPoetBundle\Entity\User: constraints: - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: email properties: email: - Email: { groups: [Registration] } plainPassword: - MinLength: { limit: 5, message: "Your password must have at least {{ limit }} characters" } name: - NotBlank: { groups: [Registration] } familyName: - NotBlank: { groups: [Registration] } sex: - Choice: { choices: [1, 2], groups: [Registration] } birthdate: - NotNull: { groups: [Registration] } city: - NotBlank: { groups: [Registration] } howDidYouHear: - Choice: { choices: [1, 2, 3, 4, 5, 6, 7, 8], groups: [Registration] } 
+6
Nov 24 '12 at 3:32
source share

validation.yml should be in your custom bundle.
/app/config/config.yml should be updated as follows:

 validation: { enabled: true, enable_annotations: false } 
-one
Sep 05
source share



All Articles