gpt4 book ai didi

symfony - 对自定义表单类型使用 sona_type_collection 而不是与另一个实体的属性/关系

转载 作者:行者123 更新时间:2023-12-04 05:43:51 24 4
gpt4 key购买 nike

是否可以使用 sonata_type_collection针对自定义表单类型而不是与另一个实体的属性/关系?

像这样的东西:

$formMapper->add('foo', 'sonata_type_collection',
array('type' => new \myVendor\myBundleBundle\Form\Type\BlockType()
));

这给我带来了以下错误
The current field `contingut` is not linked to an admin. Please create one for the target entity : ``

编辑:

像这样的事情成功了:
$formMapper->add('contingut', 'collection', array(                                 
'type' => new \myVendor\myBundleBundle\Form\Type\Block1Type(),
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false
));

最佳答案

除了示例中的自定义类型,您还可以使用 native 实体类型。

$formMapper->add('cars',
'collection',
array(
'type' => 'entity',
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'label' => false,
'options' => array(
'class' => 'YourBundle:Car',
'property' => 'name',
'label' => false
)
)
)

关于symfony - 对自定义表单类型使用 sona_type_collection 而不是与另一个实体的属性/关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10932028/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com