Пример #1
0
 public function editAction($id)
 {
     $id = (int) $id;
     $form = new VideoForm();
     $model = Video::findFirst($id);
     if ($this->request->isPost()) {
         $form->bind($this->request->getPost(), $model);
         if ($form->isValid()) {
             if ($model->save()) {
                 $this->flash->success('Информация обновлена');
                 return $this->redirect('/video/admin/edit/' . $model->getId());
             } else {
                 $this->flashErrors($model);
             }
         } else {
             $this->flashErrors($form);
         }
     } else {
         $form->setEntity($model);
     }
     $this->view->model = $model;
     $this->view->form = $form;
     $this->view->title = 'Редактирование видео';
 }
Пример #2
0
 public function addAction()
 {
     $logged = $this->getConnection();
     $form = new VideoForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $video = new Video();
         $form->setInputFilter($video->getInputFilter());
         $post = $request->getPost()->toArray();
         $post['idMembre'] = $logged;
         $form->setData($post);
         if ($form->isValid()) {
             $data = $form->getData();
             $saveVideo = array('idMembre' => $logged, 'description' => $post['description'], 'titre' => $post['titre'], 'lien' => $post['lien']);
             $video->exchangeArray($saveVideo);
             $this->getVideoTable()->saveVideo($video);
             // Redirect to list of videos
             return $this->redirect()->toRoute('video');
         }
     }
     return array('form' => $form);
 }