public function editAction()
    {
        $id = $this->params()->fromRoute('id');
        if (!$id) {
            return $this->redirect()->toRoute('csn-cms/default', array('controller' => 'category', 'action' => 'index'));
        }

        $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');

        try {
            $category = $entityManager->find('CsnCms\Entity\Category', $id);
        } catch (\Exception $ex) {
            echo $ex->getMessage(); // this will never be seen if you don't comment the redirect

            return $this->redirect()->toRoute('csn-cms/default', array('controller' => 'category', 'action' => 'index'));
        }

        $form = $this->getForm($category, $entityManager, 'Update');

        //hide the id element(bug in doctrine maybe)
        //$form->get('id')->setAttribute('type','hidden');

        try {
            $form->get('id')->setAttribute('type','hidden');
        } catch (\Exception $ex) {

        }
        $form->bind($category);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $post = $request->getPost();
            $form->setData($post);
            if ($form->isValid()) {
                //$this->prepareData($category);
                $entityManager->persist($category);
                $entityManager->flush();

            return $this->redirect()->toRoute('csn-cms/default', array('controller' => 'category', 'action' => 'index'));
            }
        }

        return new ViewModel(array('form' => $form, 'id' => $id));
    }