Sonata Admin - sonata_type_collection:现有实体列表中的 select

Sonata Admin - sonata_type_collection: select from the list of existing entities

我正在尝试使用 PageHasImage 桥接实体在 PageImage 实体之间实现多对多关系。在 PageAdmin 中,我添加了这样的字段:

->add(
      'galleryImages', 
      'sonata_type_collection', 
      array(
            'cascade_validation' => false,
            'by_reference' => false,
            'type_options' => array('delete' => false)
           ),
      array(
            'edit' => 'inline',
            'inline' => 'table',
            'sortable' => 'position',
            'admin_code' => 'sonata.admin.page_has_image'
      )
 )

这让我可以选择添加新的 Image 字段,然后上传新图片或 select 从已上传的列表中选择它。上传部分按预期工作,但是 selecting 从已上传的图像列表中执行任何操作。 Images 列表中的 Select 按钮在其 href 中只有“#”,似乎没有做任何有用的事情。列出的图像旁边也有复选框,但没有操作按钮来使用 selection。

我应该配置什么才能使列表中的操作有意义?我的猜测是关系的设置者或生命周期事件方法中缺少一些东西,但我希望得到一些指导。

好的,我可以看出这不是一个热门问题,但对于任何很快遇到这个问题的可怜人来说 - Sonata 中有一个错误。此外,我将 Sonata Admin 文档评为 4/10 ... 我花了几天时间寻找对奏鸣曲形式的各种配置参数的体面描述,确保我配置错误。度过一生的好方法,嗯。

解决方法如下:https://github.com/sonata-project/SonataDoctrineORMAdminBundle/issues/404

为了完整起见,我将其复制到这里:

在 Resources/views/CRUD/edit_orm_many_association_script.html.twig 中注释以下行可解决问题

if (this.nodeName == 'A' && (target.attr('href').length == 0 ||     target.attr('href')[0] == '#')) {
Admin.log('[{{ id }}|field_dialog_form_list_link] element is an anchor, skipping action', this);
return;

}