Zend framework2 如何从zf 2中的表单调用模型中的函数?
我正在使用zend framework 2。我想从zend表单调用模型中的函数 现在的情况是我有一个组合框&我需要绑定数据库中的数据以填充其选项和值 这是我在zend表单中选择的标签Zend framework2 如何从zf 2中的表单调用模型中的函数?,zend-framework2,Zend Framework2,我正在使用zend framework 2。我想从zend表单调用模型中的函数 现在的情况是我有一个组合框&我需要绑定数据库中的数据以填充其选项和值 这是我在zend表单中选择的标签 $this->add(array( 'name' => 'ddlcountry', 'type' => 'Zend\Form\Element\Select', 'options' => array( 'label' => 'Country
$this->add(array(
'name' => 'ddlcountry',
'type' => 'Zend\Form\Element\Select',
'options' => array(
'label' => 'Country',
'value_options' => (here I've to call function),
),
));
对于此值选项,我想调用以下模型中的函数,即我的模型中的函数:
public function fetchcountry()
{
$this->adapter = $this->getServiceLocator()->get('db');
$dbAdapterConfig = $this->adapter;
$dbAdapter = $dbAdapterConfig;
$driver = $dbAdapter->getDriver();
$connection = $driver->getConnection();
$result = $connection->execute("CALL sp_showcountry()");
$statement = $result->getResource();
$resultdata = $statement->fetchAll(\PDO::FETCH_OBJ);
return $resultdata;
}
在你写这样一个问题之前,请至少检查本页的前10个问题,因为你的问题最近已经被问了好几次;) 请参阅我在这里提供的答案: