Added basic book adding functionality

Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI
2012-08-18 11:07:36 +02:00
parent acea821bdb
commit ebb0469ae1
8 changed files with 145 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ use Symfony\Component\HttpFoundation\Response;
use KekRozsak\FrontBundle\Entity\Book;
use KekRozsak\FrontBundle\Entity\BookCopy;
use KekRozsak\FrontBundle\Form\Type\BookType;
class BookController extends Controller
{
@@ -28,6 +29,32 @@ class BookController extends Controller
);
}
/**
* @Route("/konyvtar/uj-konyv.html", name="KekRozsakFrontBundle_bookNew", options={"expose" = true})
* @Template()
*/
public function newAction()
{
$book = new Book();
$newBookForm = $this->createForm(new BookType(), $book);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$newBookForm->bindRequest($request);
if ($newBookForm->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($book);
$em->flush();
return new Response();
}
}
return array(
'form' => $newBookForm->createView(),
);
}
/**
* @Route("/sugo/konyvtar-lista.html", name="KekRozsakFrontBundle_bookListHelp")
* @Template()