gpt4 book ai didi

symfony - sonata_type_collection 的问题

转载 作者:行者123 更新时间:2023-12-01 09:21:41 24 4
gpt4 key购买 nike

我在我的管理员中包含了一个相关模型,如下所示

->add('parameters', 'sonata_type_collection', array(
'type_options' => array(
// Prevents the "Delete" option from being displayed
'delete' => false,
)
), array(
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'position',
))

包含子管理员,我可以添加一个新行。但是,当我尝试添加第二个 child 时,出现以下错误:

PropertyAccessor requires a graph of objects or arrays to operate on, but it found type "NULL" while trying to traverse path "parameters[0]" at property "0". 

我无法解释发生了什么,我正在使用 symfony 2.7.3 并使用 Admin bundle 的 dev-master 分支。不知道有没有被举报,我试过在问题列表里查了也没看到

最佳答案

你得到这个异常是因为你忘记在父构造函数中初始化子集合。

// src/AppBundle/Entity/Parent.php

function __construct() {
$this->children = new \Doctrine\Common\Collections\ArrayCollection();
}

在您的示例中,children 必须是 parameters

关于symfony - sonata_type_collection 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32130170/

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