public function updateAction() { $routeForm = new Admin_Form_Route(); $routeForm->setAction('/admin/route/update')->setMethod('post'); // get city array $cityModel = new Admin_Model_City(); $cities = $cityModel->getCityNameCityNameMap(); $routeForm->addFromToCityElement($cities); if ($this->_request->isPost()) { // get params from request $id = $this->_request->getParam('routeID'); $from = $this->_request->getParam('from'); $to = $this->_request->getParam('to'); if ($routeForm->isValid($_POST)) { $data = $routeForm->getValues(); $routeModel = new Admin_Model_Route(); $routeModel->updateRoute($data['routeID'], $from, $to, $data['boardingPoint'], $data['droppingPoint']); $this->_redirect('/admin/route/list'); } } else { // get route ID from request $id = $this->_request->getParam('id'); } // populate form $routeModel = new Admin_Model_Route(); $routeRow = $routeModel->find($id)->current(); if ($routeRow) { $routeForm->getElement('routeID')->setValue($routeRow->route_id); $routeForm->setFromToCityValue($routeRow->from_city, $routeRow->to_city); $routeForm->getElement('boardingPoint')->setValue($routeRow->boarding_point); $routeForm->getElement('droppingPoint')->setValue($routeRow->dropping_point); } $this->view->form = $routeForm; }