Related to this post I want to transform a manual adding of a form element to Annotations
in my Entity
.
The code looks like this:
$this->add(array(
'name' => 'formElementName',
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'attributes' => array(
'required' => true
),
'options' => array(
'label' => 'formElementLabel',
'empty_option' => '--- choose formElementName ---',
'object_manager' => $this->getEntityManager(),
'target_class' => 'Mynamespace\Entity\Entityname',
'property' => 'nameOfEntityPropertyAsSelect'
)
));
As an annotation I have the problem that the object_manager
is a variable which I cannot pass to annotations. Every other attribute is no problem and should work when being annotated.
I'm looking for the correct way to do this:
$form->get('formElementName').setOptions(array('object_manager'=>$entityManager)
Any ideas?