diff --git a/src/Controller/GuiController.php b/src/Controller/GuiController.php index 395b863..418e071 100644 --- a/src/Controller/GuiController.php +++ b/src/Controller/GuiController.php @@ -44,6 +44,7 @@ class GuiController extends AbstractController { 'title' => 'Joe Carstairs\' notes', 'description' => 'Joe Carstairs\' notes', 'note' => $note, + 'slug' => $slug, ]; } @@ -74,7 +75,7 @@ class GuiController extends AbstractController { $entityManager->persist($note); $entityManager->flush(); - return $this->redirectToRoute('note', ['slug' => $note->getSlug()]); + return $this->redirectToRoute('note', ['slug' => $slug]); } return $this->render('/write_note.html.twig', [ diff --git a/templates/note.html.twig b/templates/note.html.twig index 4cc29a3..0a47292 100644 --- a/templates/note.html.twig +++ b/templates/note.html.twig @@ -1,9 +1,17 @@ {% extends 'base.html.twig' %} {% block content %} - - Note - {{ note.getPublishedDate().format('c') }} - {{ note.content }} - + {% if note %} + + Note {{ note.slug }} + {{ note.publishedDate.format('c') }} + {{ note.content }} + + {% else %} + + Note not found + I don't have a note '{{ slug }}'. + Go back to Notes. + + {% endif %} {% endblock %}
{{ note.content }}
I don't have a note '{{ slug }}'.
Go back to Notes.