Added messages

This commit is contained in:
Kevin Frantz 2018-09-06 19:41:46 +02:00
parent 26c8da8b69
commit 69ea47facd

View File

@ -42,13 +42,19 @@ class UserController extends AbstractController implements UserControllerInterfa
'label' => 'register' 'label' => 'register'
]) ])
->getForm(); ->getForm();
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$task = $form->getData(); $task = $form->getData();
$entityManager = $this->getDoctrine()->getManager(); $entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($task); $entityManager->persist($task);
$entityManager->flush(); try {
$entityManager->flush();
$this->addFlash('success', 'User created!');
} catch (\Exception $exception) {
$this->addFlash('danger', 'User could not be created!');
$this->addFlash('info', $exception->getMessage());
}
} }
return $this->render("user/register.html.twig", [ return $this->render("user/register.html.twig", [
'form' => $form->createView() 'form' => $form->createView()