public function editAction()
 {
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $mediaResponseForm = new Form_TagForm($configForm->mediaResponse);
     $mediaResponseId = $this->getRequest()->getParam('id', null);
     try {
         $entity = $this->mediaResponseRepository->fetchEntity($mediaResponseId);
         $mediaResponseForm->image->setOrginValue($entity->image);
         $mediaResponseForm->file->setOrginValue($entity->file);
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage(), 404);
     }
     if ($this->getRequest()->isPost()) {
         if ($mediaResponseForm->isValid($_POST)) {
             try {
                 $mediaResponseId = $this->mediaResponseRepository->saveEntity($mediaResponseForm->getValues());
                 $mediaResponseForm->image->setOrginValue($entity->image);
                 $mediaResponseForm->file->setOrginValue($entity->file);
                 $this->_helper->systemMessages('notice', 'Medienresonanz erfolgreich gespeichert');
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 $this->_helper->systemMessages('error', 'Medienresonanz konnte nicht gespeichert werden');
             }
         }
     } else {
         $mediaResponseForm->populate($entity->toArray());
     }
     $mediaResponseForm->setAction('/admin/media-response/edit/' . $mediaResponseId);
     $this->view->form = $mediaResponseForm;
 }
예제 #2
0
 public function editAction()
 {
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $newsForm = new Form_TagForm($configForm->news);
     $newsId = $this->getRequest()->getParam('id', null);
     try {
         $entity = $this->newsRepository->fetchEntity($newsId);
         $newsForm->image->setOrginValue($entity->image);
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage(), 404);
     }
     if ($this->getRequest()->isPost()) {
         if ($newsForm->isValid($_POST)) {
             try {
                 $values = $newsForm->getValues();
                 $values['user'] = $this->currentUserEntity;
                 $newsId = $this->newsRepository->saveEntity($values);
                 $newsForm->image->setOrginValue($entity->image);
                 $this->_helper->systemMessages('notice', 'News erfolgreich gespeichert');
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 $this->_helper->systemMessages('error', 'News konnte nicht gespeichert werden');
             }
         }
     } else {
         $newsForm->populate($entity->toArray());
     }
     $newsForm->setAction('/admin/news/edit/' . $newsId);
     $this->view->form = $newsForm;
 }