2
任何人都可以告诉我为什么与表单集合相关的错误在特定字段外部显示,以及如何将它移动到您在以下图像中看到的位置?Symfony 3 - 在字段外部显示表单集合字段错误
本场代码:
/**
* @Assert\Valid
* @ORM\OneToMany(
* targetEntity="PageFile",
* mappedBy="page",
* cascade={"persist","remove"},
* orphanRemoval=true
*)
* @var PageFile[]
* @Assert\Count(max="1")
*/
private $pageFiles;
配置:
- property: 'pageFiles'
type: 'collection'
type_options:
entry_type: 'Notimeo\PageBundle\Form\Type\MyFileType'
by_reference: false
error_bubbling: false
我使用EasyAdminBundle这是我的整个项目:https://github.com/ktrzos/SymfonyBasic。问题适用于“Notimeo \ PageBundle”。
'选项 “cascade_validation” 不exist.' –
我看到,海报正在使用Symfony 2.1。我在这里使用Symfony 3.0.1。它可以有所作为。 –
它看起来像在Symfony3中被删除了,我不知道你使用的是什么版本。请参阅Symfony 2.8 doc:http://symfony.com/doc/2.8/reference/forms/types/form.html#cascade-validation。他们建议使用有效约束,而不是http://symfony.com/doc/current/reference/constraints/Valid.html – martin