Php SonataAdminBundle sonata_类型_集合未显示字段

Php SonataAdminBundle sonata_类型_集合未显示字段,php,symfony,sonata-admin,Php,Symfony,Sonata Admin,我用的是索纳塔。我想在我的创建表单中添加一对多关系对象的功能。因此,我尝试使用索纳塔类型的集合,如下所示: $formMapper->add('attachments', 'sonata_type_collection', array( 'label' => 'Attachments', // Prevents the "Delete" option from being displayed

我用的是索纳塔。我想在我的创建表单中添加一对多关系对象的功能。因此,我尝试使用索纳塔类型的集合,如下所示:

$formMapper->add('attachments', 'sonata_type_collection', array(
                    'label' => 'Attachments',
                    // Prevents the "Delete" option from being displayed
                    'type_options' => array('delete' => false)
                ), array(
                    'edit' => 'inline',
                    'inline' => 'table',
                    'sortable' => 'position',
                ))
        ->add('attachments', 'sonata_type_collection', array(
            'label' => 'Attachments',
        ), array(
            'class' => 'Model:Name',
            'target_entity' => '\\Namespace\\To\\Entity',
            'allow_delete' => false,
            'multiple' => true,
            'expanded' => false,
            'admin_code' => 'sonata.admin.setting',
            'edit' => 'inline',
            'inline' => 'table',
        ))
但我的创建表单只呈现字段的一个标签,仅此而已


提前感谢您的所有建议:)

尝试以下方法:

$formMapper->add('attachments', 'sonata_type_collection', array(
                    'label' => 'Attachments',
                    // Prevents the "Delete" option from being displayed
                    'type_options' => array('delete' => false)
                ), array(
                    'edit' => 'inline',
                    'inline' => 'table',
                    'sortable' => 'position',
                ))
        ->add('attachments', 'sonata_type_collection', array(
            'label' => 'Attachments',
        ), array(
            'class' => 'Model:Name',
            'target_entity' => '\\Namespace\\To\\Entity',
            'allow_delete' => false,
            'multiple' => true,
            'expanded' => false,
            'admin_code' => 'sonata.admin.setting',
            'edit' => 'inline',
            'inline' => 'table',
        ))

谢谢你的回复。你能解释一下什么是Model:Name和admin_code吗?
Model:Name
将是实体快捷方式名称,你可以使用它来代替完整的类名。请参见,您的模型类似于
Acme\DemoBundle\Entity\EntityName
,或者您可以使用
AcmeDemoBundle:EntityName
这里将解释
管理代码。希望这能帮上忙。好吧,我显然错过了一些东西。当我按照你们的建议做的时候,附件显示在编辑一个对象上,而不是在创建页面上。它很有效,非常感谢你们,我已经找了好几个星期了