Example #1
0
 public function editAction()
 {
     $this->view->title = $this->view->translate("Edit address");
     $this->view->id = $id = $this->_getParam('id');
     $sub_id = $this->_getParam('subId');
     //load address form with two arguments record id and module id
     $addForm = new Address_Form_Address($this->_getParam('id'), $this->_getParam('subId'));
     $this->view->form = $addForm;
     //geting module names and make dynamically redirect action...
     $addressmodel = new Address_Model_addressInformation();
     $module_name = $addressmodel->getmodule($this->view->subId);
     foreach ($module_name as $module_view) {
         $path1 = $module_view['module_description'] . 'commonview';
     }
     $path1 = $this->view->path1 = strtolower($path1);
     //set the address details value in the address form
     $edit_address = $addressmodel->getaddress($id, $sub_id);
     $addForm->populate($edit_address[0]);
     //update the address details...
     if ($this->_request->isPost() && $this->_request->getPost('Update')) {
         $formData = $this->_request->getPost();
         if ($addForm->isValid($formData)) {
             $olddate = $this->view->adm->editRecord("ourbank_address", $id);
             $this->view->adm->updateLog("ourbank_address_log", $olddate[0], $this->view->createdby);
             $addressmodel->updateRecord("ourbank_address", $id, $addForm->getValues(), $sub_id);
             $this->_redirect('/' . $path1 . '/index/commonview/id/' . $id);
         }
     }
 }