sonata_type_collection 的问题

Issue with sonata_type_collection

我已经在我的后台添加了一个相关模型如下

->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 管理员,我可以添加新行。但是,当我尝试添加第二个 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 并使用管理包的 dev-master 分支。 不知道有没有人报道过,我去issues list里查过,没看到

您出现该异常是因为您忘记在父构造函数中初始化子集合。

// src/AppBundle/Entity/Parent.php

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

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