我正在使用collectiontype
中的票证字段formbuilder
并尝试为其添加服务器端验证。但是只有在添加断言验证时我才会遇到一些错误。
我的实体:
/**
* @Assert\Length(
* min = 1,
* max = 10,
* minMessage = "Atlest one ticket to be added",
* maxMessage = "Not allowed"
* )
*
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\EventTicket", inversedBy="events", cascade={"persist"})
*/
public $tickets;
我的表格:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('tickets', CollectionType::class, [
'entry_type' => EventTicketType::class,
'allow_add' => true,
'allow_delete' => true
]
);
}
我收到此错误:
给定“字符串”类型的预期参数,“Doctrine\ORM\PersistentCollection”。