public function editAction()
 {
     $session = new Container('admin');
     if (!$session->offsetExists('email')) {
         $this->redirect()->toRoute('admin', array('action' => 'login'), array('query' => array('status' => 'u_login')));
     }
     $form = new CountryForm();
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('country', array('action' => 'add'));
     }
     try {
         $country = $this->getCountryTable()->getCountry($id);
     } catch (\Exception $ex) {
         return $this->redirect()->toRoute('country', array('action' => 'index'));
     }
     $form->bind($country);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setInputFilter($country->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $this->getCountryTable()->saveCountry($country);
             return $this->redirect()->toRoute('country');
         }
     }
     return array('id' => $id, 'form' => $form);
 }
 public function editAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('country', array('action' => 'add'));
     }
     $country = $this->getEntityManager()->find('Application\\Entity\\Country', $id);
     if (!$country) {
         return $this->redirect()->toRoute('country', array('action' => 'index'));
     }
     $form = new CountryForm();
     // CSS
     $form->get('name')->setAttribute('class', 'form-control');
     $form->bind($country);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setInputFilter($country->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $this->getEntityManager()->flush();
             // Redirect to list of albums
             return $this->redirect()->toRoute('country');
         }
     }
     return array('id' => $id, 'form' => $form);
 }