0
在ZF2,假設我在表單中有一個Select
:ZF2獲取值從數據庫到窗體類
$this->add([
'type' => 'Zend\Form\Element\Select',
'name' => 'someName',
'attributes' => [
'id' => 'some-id',
],
'options' => [
'label' => 'Some Label',
'value_options' => [
'1' => 'type 1',
'2' => 'type 2',
'3' => 'type 3',
],
],
]);
我怎樣才能把值「類型1」,「2型」,「3型」等從數據庫查詢到value_options
?
男人,你搖滾!在SO上閱讀你的其他答案。你很棒! –
只需要注意一點:在表單中,我需要將此元素添加到'public function init()'中,作爲zend文檔的鏈接。 –
你可以告訴,如何將一個額外的參數('$ id')傳遞給'TypeSelectFactory'的'$ typeService = $ serviceManager-> get('Some \\ Service \\ That \\ Executes \\ Queries') ;'? –