i used Doctrine for create a DoctrineModule\Form\Element\ObjectSelect in my forms. But shows me these error: "No object manager was set". I based in the guide of Doctrine Module . I carry a time searching but can´t find whats is wrong. The code:
The form:
<?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...
}