I know that zend framework have some easy ways to do this, but i didn't found a good answer or tutorial to do things according to zend.
Some answers show how to do without JSON, others without Jquery View Helper, and others without using zend framework.
The thing is too simple We have 2 Selects: group and subgroup When I change group, the subgroup is populated.
This is the action:
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;
}
And this is the form
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();
}
I want to know where to put on form the request to 'getSubgroupAction' or what i have to do using jquery view helper to get the json response from the action.
Note: This is not a working example.
I antecipate my thanks for the attention and the help. tkzalot.