Ejemplo n.º 1
0
 public function addAction()
 {
     $form = new AlbumForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->populate($form->getData());
             $this->getEntityManager()->persist($album);
             $this->getEntityManager()->flush();
             return $this->redirect()->toRoute('album');
         }
     }
     return array('form' => $form);
 }
Ejemplo n.º 2
0
 public function addAction()
 {
     $form = new AlbumForm();
     $form->get('submit')->setAttribute('label', 'Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->exchangeArray($form->getData());
             $this->getEntityManager()->persist($album);
             $this->getEntityManager()->flush();
             // Redirect to list of albums
             return $this->redirect()->toRoute('dalbum');
         }
     }
     return array('form' => $form);
 }
Ejemplo n.º 3
0
 public function addAction()
 {
     $viewModel = $this->getViewModel();
     $form = new AlbumForm();
     $form->get('submit')->setAttribute('value', 'Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->exchangeArray($form->getData());
             $this->getAlbumTable()->saveAlbum($album);
             // Redirect to list of albums
             return $this->redirect()->toRoute('album-front-album');
         }
     }
     return $viewModel->setVariables(array('form' => $form));
 }