【发布时间】:2016-08-03 21:31:53
【问题描述】:
谁能告诉我如何解决这个错误“没有设置对象管理器”
这是字段集:
namespace Trunk\Form;
use Trunk\Entity\Category;
use Doctrine\Common\Persistence\ObjectManager;
use DoctrineModule\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator;
use Zend\Form\Fieldset;
use Zend\InputFilter\InputFilterProviderInterface;
class CategoryFieldset extends Fieldset implements InputFilterProviderInterface
{
public function __construct($objectManager)
{
parent::__construct('category');
$this->setHydrator(new DoctrineHydrator($objectManager, 'Trunk\Entity\Category'));
$this->add(array(
'type' => 'DoctrineORMModule\Form\Element\DoctrineEntity',
'name' => 'title',
'object_manager' => $objectManager,
'target_class' => 'Trunk\Entity\Category',
'property' => 'title',
'is_method' => false,
'find_method' => array(
'name' => 'findBy',
'params' => array(
'criteria' => array('parentid' => 0),
'orderBy' => array('title' => 'ASC'),
),
)
));
}
}
这是错误信息:
F:\xampp\htdocs\travelltheworld\vendor\doctrine\doctrine-module\src\DoctrineModule\Form\Element\Proxy.php:535
没有设置对象管理器
我已将工厂中的实体管理器注入到名为 ProductForm 的表单中。在该表单中,我有一个名为 ProductFieldset 的基本字段集,在 ProductFieldset 中,我插入了 CategoryFieldset,我需要从数据库中选择类别并将它们显示在选择框中。
如果您需要更多代码或解释,请询问我。
【问题讨论】:
标签: forms doctrine-orm zend-framework2 fieldset