public function editttAction()
 {
     $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $form = new StudentForm($entityManager);
     $person = new Student();
     $form->bind($person);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $dataForm = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $form->setValidationGroup(array('student' => array('year', 'term', 'section', 'admNo', 'admDate')));
         //set data post and file ...
         $form->setData($dataForm);
         if ($form->isValid()) {
             //var_dump($form->getData());
             $entityManager->persist($person);
             $entityManager->flush();
             return $this->redirect()->toRoute('student', array('controller' => 'student', 'action' => 'index'));
         }
     }
     return new ViewModel(array('form' => $form));
 }
 public function editAction()
 {
     $entityManager = $this->getOM();
     $viewmodel = new ViewModel();
     $ud = $this->zfcUserAuthentication()->getIdentity()->getId();
     $iud = $this->getOM()->getRepository('Admin\\Entity\\Student')->findOneBy(array('user' => $ud));
     $id = $iud->getId();
     if (!$id) {
         return $this->redirect()->toRoute('students', array('controller' => 'students', 'action' => 'dashboard'));
     }
     $student = $entityManager->find('Admin\\Entity\\Student', $id);
     $image = $student->getImage();
     if (!$student) {
         return $this->redirect()->toRoute('students', array('controller' => 'students', 'action' => 'dashboard'));
     }
     $form = new StudentForm($entityManager);
     $form->bind($student);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $dataForm = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $form->setData($dataForm);
         //exclude section and year from being validated
         $form->setValidationGroup(array('student' => array('image', 'person' => array('fname', 'lname', 'mname', 'mobile', 'address', 'country', 'state', 'lga', 'dob', 'sex', 'religion', 'nokName', 'nokRel', 'nokMobile'))));
         if ($form->isValid()) {
             $pre = $form->getData('student');
             $data = $pre->getImage();
             if (!$data) {
                 $student->setImage($image);
             }
             $student->setCurrentclass($pre->getClass());
             $entityManager->persist($student);
             $entityManager->flush();
             // Redirect to list of albums
             return $this->redirect()->toRoute('students', array('controller' => 'students', 'action' => 'dashboard'));
         }
     }
     $viewmodel->setVariables(array('form' => $form, 'id' => $id, 'image' => $image));
     return $viewmodel;
 }