Skip to content

Instantly share code, notes, and snippets.

@gpfiel
Created November 19, 2013 14:40
Show Gist options
  • Save gpfiel/7546320 to your computer and use it in GitHub Desktop.
Save gpfiel/7546320 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());
echo '<pre>';
print_r($request->getPost());
if ($form->isValid()) {
print_r('form válido');
exit;
$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');
}
echo '<pre>';
print_r('não ´vlaido');
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment