public function indexAction() { $busca = $this->_request->getParam('id'); $ingredienteModel = new Application_Model_Ingrediente(); $nome_ingrediente = $ingredienteModel->fetchAll($ingredienteModel->select()->from($ingredienteModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_ingrediente'))->where('id_ingrediente like :busca')->bind(array('busca' => '%' . $busca . '%'))); $this->view->nome_ingrediente = $nome_ingrediente[0]['nome_ingrediente']; $relacionamentosModel = new Application_Model_Relacionamentos(); $this->view->relacionamento = $relacionamentosModel->fetchAll($relacionamentosModel->select()->where('excluido = 0')->where('id_ingrediente = ?', $busca)->order('id_ingrediente_idx DESC')); }
public function editarAction() { $id = $this->_request->getParam('id'); require_once APPLICATION_PATH . '/modules/admin/forms/Ingrediente.php'; $this->view->form = new admin_Form_Ingrediente(); $ingredienteModel = new Application_Model_Ingrediente(); if ($this->_request->isPost()) { $this->view->form->setDefaults($this->_request->getPost()); $data = $this->view->form->getValues(); if ($this->view->form->isValid($data)) { $ingredienteModel->update($data, 'id_ingrediente = ' . $id); return $this->_helper->redirector('index'); } } $ingrediente = $ingredienteModel->find($id)->current(); $this->view->form->setDefaults($ingrediente->toArray()); }