Skip to content

Instantly share code, notes, and snippets.

@fabiocarneiro
Forked from gpfiel/AlbumContollrer.php
Last active December 28, 2015 19:09
Show Gist options
  • Save fabiocarneiro/7547813 to your computer and use it in GitHub Desktop.
Save fabiocarneiro/7547813 to your computer and use it in GitHub Desktop.
<?php
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());
return array('form' => $form);
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');
}
}
}
@ricardofiorani
Copy link

Tá escrito errado o nome do arquivo.

@fabiocarneiro
Copy link
Author

é um gist, o nome do arquivo pouco importa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment