我知道zend框架有一些簡單的方法可以做到這一點,但我沒有找到一個好的答案或教程來根據zend來做事情。如何用Jquery View Helper和JSON填充選擇(ZEND)
一些答案顯示如何不使用JSON,其他人不使用Jquery View Helper, 和其他人不使用zend框架。
事情太簡單 我們有2個選擇:組和子組 當我改變組時,子組被填充。
這是操作:
public function getSubgroupAction(){
$model = new MySubgroupModel();
$id = $this->getRequest()->getParam('id');
$where = "id = $id";
$data = $model->fetchAll($where)->toArray();
$json = Zend_Json::encode($data);
return $json;
}
這是我想知道在哪裏的要求提上形式爲「getSubgroupAction」還是什麼形式
public function init(){
$model = new MyGroupModel();
$options = $model->fetchAll();
// $options receive a query with id and name
$group = new Zend_Form_Element_Select('group');
$group->setLabel('Chose Group')
->addMultiOptions($options)
->setRequired();
$subgroup = new Zend_Form_Element_Select('subgroup');
$subgroup->setLabel('Chose Subgroup')
->setRequired();
}
我一直在使用做jquery視圖助手從動作獲取json響應。
注意:這不是一個工作示例。
我非常感謝您的關注和幫助。 tkzalot。
沒人能給出這個問題的答案嗎?我也對這個答案感興趣! – JellyBelly 2011-06-23 08:26:16