示例#1
0
 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);
 }
示例#2
0
 public function bankaddAction()
 {
     $this->_checkIfUserIsLoggedIn();
     $form = new BankForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $bank = new Bank();
         $form->setInputFilter($bank->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $bank->exchangeArray($form->getData());
             $this->getEntityManager()->persist($bank);
             $this->getEntityManager()->flush();
             return $this->redirect()->toRoute('admin/default', array('controller' => 'bank', 'action' => 'bank'));
         }
     }
     return new ViewModel(array('form' => $form, 'scc' => $this->flashMessenger()->getCurrentSuccessMessages(), 'err' => $this->flashMessenger()->getCurrentErrorMessages()));
 }