Created
November 19, 2013 16:20
-
-
Save gpfiel/7547948 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function addAction() | |
{ | |
$album = new Album; | |
$form = new AlbumForm($this->getEntityManager()); | |
$form->setHydrator(new DoctrineEntity($this->getEntityManager(),'Admin\Entity\Album')); | |
$form->bind($album); | |
$request = $this->getRequest(); | |
if ($request->isPost()) { | |
$form->setInputFilter($album->getInputFilter()); | |
$form->setData($request->getPost()); | |
echo '<pre>'; | |
var_dump($form->isValid()); | |
exit; | |
if ($form->isValid()) { | |
$em = $this->getEntityManager(); | |
$em->persist($album); | |
$em->flush(); | |
$this->pluginMensagem()->adicionarMensagem($this->params('action'),'ok', "O álbum <strong>{$album->title}</strong> foi adicionado."); | |
return $this->redirect()->toRoute('album'); | |
} | |
} | |
return new ViewModel(array( | |
'album' => $album, | |
'form' => $form | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment