我使用学说来创建我的表单中的doctrinemodule form element element objectSelect。但是向我展示了这些错误:"没有设置对象管理器"。我基于学说模块指南。我有时间搜索,但无法找到什么错。代码:
表格:
<?php
//.....
use DoctrineModulePersistenceObjectManagerAwareInterface;
use DoctrineCommonPersistenceObjectManager;
use ZendFormForm;
class SubRubroForm extends Form implements ObjectManagerAwareInterface
{
private $value_submit;
private $objectManager;
public function __construct($value_submit)
{
$this->value_submit=$value_submit;
// Define form name
parent::__construct('SubRubro-form');
// Set POST method for this form
$this->setAttribute('method', 'post');
$this->addElements();
$this->addInputFilter();
$this->init();
}
public function init()
{
$this->add([
'type' => 'DoctrineModuleFormElementObjectSelect',
'name' => 'rubro',
'options' => [
'object_manager' => $this->getObjectManager(),
'target_class' => 'RubrosEntityRubro',
'property' => 'nombre',
],
]);
}
// ... add others elements addElements(){} ....
// ... inputfilters ....
// ... set and get ObjectManager() interface methods...
}
添加父亲类元素的init()方法。
类Subrubroform扩展表单实现ObjectManagerawareInterface {private $ value_submit;私人$ objectmanager;
public function __construct($value_submit)
{
$this->value_submit=$value_submit;
// Define form name
parent::__construct('SubRubro-form');
// Set POST method for this form
$this->setAttribute('method', 'post');
$this->addElements();
$this->addInputFilter();
$this->init();
}
public function init()
{
$this->add([
'type' => 'DoctrineModuleFormElementObjectSelect',
'name' => 'rubro',
'options' => [
'object_manager' => $this->getObjectManager(),
'target_class' => 'RubrosEntityRubro',
'property' => 'nombre',
],
]);
parent::init();
}
// ... add others elements addElements(){} ....
// ... inputfilters ....
// ... set and get ObjectManager() interface methods...