【发布时间】:2018-01-08 13:12:04
【问题描述】:
我在AssignmentTypeAdmin中有这个方法:
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('code', 'text')
->add('label', 'text', array('label'=>'Libellé'))
->add('assignHierarchyNode.label', 'text', array('label' => 'Noeud hiérarchique'))
->add('assignPortfolioType.portfolioTypeLabel', null, array('label' => 'Type de portefeuille'))
->add('assignGeoHierarchyNodeType.label', null, array('label' => 'Type de noeud hiérarchique'));
}
在 AssignmentType 类中:
/**
* @ORM\ManyToOne(targetEntity="HierarchyManagerBundle\Entity\HierarchyNode")
* @ORM\JoinColumn(name="assign_hierarchy_node_id", referencedColumnName="id", nullable=FALSE)
*/
private $assignHierarchyNode;
在 HierarchyNode 类中: ...
/**
* @var string
* @Gedmo\TreePathSource
* @ORM\Column(name="label", type="string", length=255)
*/
private $label;
... 还有get和set方法。
我的问题是我收到此错误,但我不知道为什么:
PropertyAccessor 需要对象或数组的图形来操作,但它在尝试遍历属性“label”处的路径“assignHierarchyNode.label”时发现类型“NULL”。
我为此使用 Symfony 3.1、Doctrine 2.5.2、Sonata Bundle。 提前谢谢!
【问题讨论】:
-
您的 _constructor 工作得如何?在您的数据库中,链接表的 id 是 register ?
-
@Jeremy 你太棒了!这就对了! __constructor 不行。
标签: php symfony doctrine sonata