与this post相关,我想在我的Entity
中将手动添加表单元素转换为Annotations
。
代码如下所示:
$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'
)
));
作为一个批注,我有一个问题,object_manager
是一个我不能传递给批注的变量。其他所有属性都是没有问题的,在被注释时应该可以工作。
我正在寻找正确的方法来做到这一点:
$form->get('formElementName').setOptions(array('object_manager'=>$entityManager)
有什么想法吗?
发布于 2013-02-13 17:03:23
你一定要试试这个,它会很好用的。
<!-- language-all: lang-html -->
foreach($cityArr as $city){
$city_ar[$city['id']] = $city['city'];
}
$form->user_city->setMultiOptions($city_ar);
$form->user_city->setValue($val["user_city"]);
https://stackoverflow.com/questions/14157298
复制相似问题