Zend フレームワーク 2 を使用しています。モデル内の関数を zend フォームから呼び出したいと考えています。
状況は、コンボボックスを持っていて、データベースからデータをバインドしてオプションと値を入力する必要があるということです。
これは zend 形式の私の select タグです
$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;
}