我的问题如下。我正在使用Symfony的Sonata Admin。在管理部分,当我试图创建一个实体,没事的时候我点击添加按钮(拼写为“Ajouter”)显示:如何在嵌套管理器中执行嵌入式编辑?
我收到以下错误:Call to a member function getName() on a non-object
在Chrome控制台
这里是我的实体层次是怎么了,我有一个在下面的方式联系在一起的三个对象:
Video ---OneToOne--> String ---OneToMany--> LocalizedString
简单地说,我有一个视频,将有一个标题和这个称号将被翻译。这里是我的实体:
LocalizedString
OSC\UtilsBundle\Entity\LocalizedString:
type: entity
table: null
repositoryClass: OSC\UtilsBundle\Entity\LocalizedStringRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
locale:
type: string
length: '20'
content:
type: string
length: 255
manyToOne:
parent:
targetEntity: String
mappedBy: localizedObjects
lifecycleCallbacks: { }
字符串
OSC\UtilsBundle\Entity\String:
type: entity
table: null
repositoryClass: OSC\UtilsBundle\Entity\StringRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
oneToMany:
localizedObjects:
targetEntity: LocalizedString
mappedBy: parent
cascade: ["persist", "remove"]
lifecycleCallbacks: { }
视频
OSC\MySportBundle\Entity\Video:
type: entity
table: null
repositoryClass: OSC\MySportBundle\Entity\VideoRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
oneToOne:
title:
targetEntity: OSC\UtilsBundle\Entity\String
cascade: ["persist", "remove"]
lifecycleCallbacks: { }
所以,我做了这个结构以方便在SonataAdmin中进行编辑。如果通过管理仪表板,我想编辑一个字符串,我可以轻松地编辑一个字符串并以多种语言翻译它(这已经有效)。
但是,当我尝试在视频管理中执行此操作时,似乎无法对String对象进行内联编辑(单击添加按钮不起作用)。
下面是视频管理类的相关代码:
$formMapper
->add('title', 'sonata_type_admin', array('delete' => false, 'btn_add' =>false), array(
'edit' => 'inline',
'inline' => 'table',
));
从我发现,它看起来就像两个鳞片状的形式是不可能的?有没有办法规避这种限制?或者,也许这是我的设计不太好?
EDIT1:它看起来像有在GitHub的补丁:https://github.com/sonata-project/SonataAdminBundle/pull/1971#issuecomment-58023124
如果有谁知道我该如何使用它,我将不胜感激。
只需使用'sonata_type_model'并传递相关选项以获得更好的控制 – 2014-12-16 14:47:27
您是否尝试过使用sonata_type_collection而不是sonata_type_admin与inline =>'table''的'inline'=>'standard''? – 2016-11-25 00:36:42
还有什么是您的StringAdmin? – 2016-11-25 00:38:51