Symfony2 - Validation not working for embedded Form Type

后端 未结 8 1390
北海茫月
北海茫月 2020-12-07 12:59

I have a form that combines two entities (User and Profile).

Validation seems to work on the first part of the form that comes form the User Entity and is the basis

8条回答
  •  北海茫月
    2020-12-07 13:38

    I was looking for the exact same thing and here is what I found

    http://symfony.com/doc/master/book/forms.html#forms-embedding-single-object

    You need to tell the main entity to validate it's sub entities like so:

    /**
     * @Assert\Type(type="AppBundle\Entity\Category")
     * @Assert\Valid()
     */
     private $subentity;
    

    I've tested this on symfony 2.8 and it works.

提交回复
热议问题