0
我有一個簡單的問題關於Doctrine模塊對象選擇。學說模塊objectSelect setvalue不起作用
我有一個簡單objectSelect表單元素
$this->add(array(
'name' => 'timezone',
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'options' => array(
'label' => _('Timezone:'),
'label_attributes' => array('class' => 'required'),
'object_manager' => $this->getEntityManager(),
'target_class' => 'Application\Entity\Timezones',
'property' => 'timezone',
'is_method' => true,
'find_method' => array(
'name' => 'FindAll',
),
),
));
現在我想選擇一個特定的選項爲默認,我已經使用了setValue方法來做到這一點,但它無法正常工作。
$this->get('timezone')->setValue(335);
有誰知道這是爲什麼?
非常感謝提前。
是否有任何時區與編號335? – danopz
是的,在生成的HTML的選項列表中。 – Garry