Answer the question
In order to leave comments, you need to log in
Symfony2: How to validate a form collection?
There is the essence of contests and there is the essence of prizes. In the prizes there are fields "place" and "prize name".
Entities are connected by a one-to-many relationship.
The essence of competitions
/**
* @ORM\OneToMany(targetEntity="Prize", mappedBy="contest", cascade={"persist"})
*
*/
protected $prizes;
/**
* @ORM\ManyToOne(targetEntity="Contest", inversedBy="prizes")
* @ORM\JoinColumn(name="contest_id", referencedColumnName="id")
*/
protected $contest;
/**
* @ORM\OneToMany(targetEntity="Prize", mappedBy="contest", cascade={"persist"})
* @Assert\Collection(
* fields = {
* "place" = @Assert\NotBlank(),
* "name" = @Assert\NotBlank(),
* },
* allowMissingFields = true
* )
*
*/
protected $prizes;
Answer the question
In order to leave comments, you need to log in
If you are using FormType then look this way stackoverflow.com/questions/10138505/symfony2-vali...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question