public function update($id, $data) { $data['id'] = $id; $bank = $this->getBankTable()->getBank($id); $form = new BankForm(); $form->bind($bank); $form->setInputFilter($bank->getInputFilter()); $form->setData($data); if ($form->isValid()) { $dataArr['id'] = $data['id']; $dataArr['name'] = $data['name']; $dataArr['active'] = $data['active']; $dataArr['price'] = $data['price']; $bank->exchangeArray($dataArr); $returnid = $this->getBankTable()->updateBank($bank); } return new JsonModel(array('data' => $returnid)); }
public function editAction() { $this->init(); $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('bank', array('action' => 'add')); } $bank = $this->getBankTable()->getBank($id); //echo '<pre>'; print_r($bank); //echo $bank->name; // exit; $form = new BankForm(); $form->bind($bank); //$form->get('submit')->setValue('Edit'); $form->get('submit')->setAttribute('value', 'Save'); $request = $this->getRequest(); if ($request->isPost()) { // $haircolor = new Haircolor(); $form->setInputFilter($bank->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $name = $request->getPost('name'); $price = $request->getPost('price'); $active = $request->getPost('active'); $dataArr['name'] = $name; $dataArr['active'] = $active; $dataArr['bucks'] = $request->getPost('bucks'); $dataArr['gold_coins'] = $request->getPost(gold_coins); $dataArr['price'] = $price; $dataArr['id'] = $request->getPost('id'); $bank->exchangeArray($dataArr); $this->getBankTable()->updateBank($bank); return $this->redirect()->toRoute('bank', array('action' => 'index')); } } return array('id' => $id, 'form' => $form, 'bank' => $bank); }
public function editAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('admin/bank', array('action' => 'add')); } $bank = $this->getBankTable()->get($id); $form = new BankForm(); $form->bind($bank); $request = $this->getRequest(); if ($request->isPost()) { $form->setInputFilter($bank->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $this->getBankTable()->save($form->getData()); return $this->redirect()->toRoute('admin/bank'); } } return array('id' => $id, 'form' => $form, 'config' => $this->config); }
public function bankeditAction() { $this->_checkIfUserIsLoggedIn(); $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('admin/default', array('controller' => 'bank', 'action' => 'bankadd')); } $bank = $this->getEntityManager()->find('Admin\\Entity\\Bank', $id); if (!$bank) { return $this->redirect()->toRoute('admin/default', array('controller' => 'bank', 'action' => 'bank')); } $form = new BankForm(); $form->bind($bank); $form->get('save')->setAttribute('value', 'Edit'); $request = $this->getRequest(); if ($request->isPost()) { $form->setInputFilter($bank->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $this->getEntityManager()->flush(); return $this->redirect()->toRoute('admin/default', array('controller' => 'bank', 'action' => 'bank')); } } return array('id' => $id, 'form' => $form); }