【发布时间】:2014-10-10 17:38:22
【问题描述】:
我有一个奇怪的情况,我的添加表单运行良好,但编辑表单甚至无法加载。相反,我收到以下错误:
注意:未定义的属性:/vendor/zendframework/zendframework/library/Zend/Form/Element/Collection.php 第 517 行中的 DoctrineModule\Form\Element\ObjectSelect::$object
致命错误:类名必须是 /vendor/zendframework/zendframework/library/Zend/Form/Element/Collection.php 第 517 行中的有效对象或字符串
我有 Application\Model\Record 类的对象,它们与 Application\Model\Subject 类的对象具有多对多关系。我希望Subjects 在Record 表单中显示为下拉列表,并可选择添加多个Subjects。所以在RecordFieldset.php我有:
$this->add(array(
'name' => 'subjects',
'type' => 'Zend\Form\Element\Collection',
'options' => array(
'label' => 'Subjects',
'count' => 1,
'should_create_template' => true,
'allow_add' => true,
'allow_remove' => true,
'template_placeholder' => '__subjectindex__',
'target_element' => array (
'name' => 'subject',
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'options' => array(
'object_manager' => $this->objectManager,
'target_class' => 'Application\Model\Subject',
'property' => 'name',
'empty_option' => 'Select a subject',
),
'attributes' => array(
'class' => 'form-control',
),
),
),
));
就像我说的,这在记录添加表单中非常有效。但它看起来像在编辑表单上无法加载主题。有没有其他人尝试过这样的事情?或者你知道错误在说什么吗?
环境:
Zend 框架 2.3.3
Doctrine-orm-module 0.8.0
教义 2.4.2
【问题讨论】:
标签: orm doctrine-orm zend-framework2