学说表单元素+ zf3错误messaje“没有设置对象管理器”

问题描述:

我用Doctrine在我的表单中创建DoctrineModule \ Form \ Element \ ObjectSelect。但是向我展示这些错误:“没有设置对象管理器”。我基于Doctrine Module的指导。我有时间搜索,但无法找到什么是错的。代码:学说表单元素+ zf3错误messaje“没有设置对象管理器”

形式:

<?php 
//..... 
use DoctrineModule\Persistence\ObjectManagerAwareInterface; 
use Doctrine\Common\Persistence\ObjectManager; 
use Zend\Form\Form; 

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' => 'DoctrineModule\Form\Element\ObjectSelect', 
      'name' => 'rubro', 
      'options' => [ 
       'object_manager' => $this->getObjectManager(), 
       'target_class' => 'Rubros\Entity\Rubro', 
       'property'  => 'nombre', 
      ], 
     ]); 
    } 
// ... add others elements addElements(){} .... 
// ... inputfilters .... 
// ... set and get ObjectManager() interface methods... 

} 

从父类元素的的ObjectManager加载罚款添加init()方法。

class SubRubroForm extends Form implements 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' => 'DoctrineModule\Form\Element\ObjectSelect', 
     'name' => 'rubro', 
     'options' => [ 
      'object_manager' => $this->getObjectManager(), 
      'target_class' => 'Rubros\Entity\Rubro', 
      'property'  => 'nombre', 
     ], 
    ]); 
    parent::init(); 
} 
// ... add others elements addElements(){} .... 
// ... inputfilters .... 
// ... set and get ObjectManager() interface methods...