Validation of a form - I'm getting the labels two times

前端 未结 2 1469
清歌不尽
清歌不尽 2021-01-02 18:51

I have a registration form - from FOSUserBundle this is in the template:

{% form_theme form \'AcmeMyBundle:Form:errors.html.twig\' %}

   
2条回答
  •  清酒与你
    2021-01-02 19:25

    Ok, this is a known issue.

    Let's have a look here : https://github.com/symfony/symfony/issues/2605

    The solution is : create your own validation group for properties' validation rules you want to override. In your validation.xml, put only properties you want some different rules, and define validation on a new validation group.

    So, for validation.xml, to modify only plainPassword validation rules for your entity (Acme\MyBundle\Entity\User) :

    
    
    
         
    
            
                
                    
                    
                
                
                    
                    
                    
                
            
         
    
    
    

    And now you have to state that you use different validation groups for the impacted forms (registration and profile). Fortunately, FOSUserBundle is a good practices' example and allows you to override them in your config.yml :

    fos_user:
        registration:
            form:
                validation_groups: [Default, RegistrationAcme]
        profile:
            form:
                validation_groups: [Default, ProfileAcme]
    

提交回复
热议问题