From 88be0086ce278a5364a0cb52b72da8f15f03fb30 Mon Sep 17 00:00:00 2001 From: allavenavr Date: Thu, 12 Dec 2024 14:41:59 +0100 Subject: [PATCH] message --- src/Controller/MessageController.php | 5 +++++ src/Form/MessageType.php | 10 ++-------- templates/base.html.twig | 6 +++--- templates/index/index.html.twig | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Controller/MessageController.php b/src/Controller/MessageController.php index f46276b..55eb5ba 100644 --- a/src/Controller/MessageController.php +++ b/src/Controller/MessageController.php @@ -30,6 +30,10 @@ final class MessageController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { + + $message->setSendingDate(new \DateTime()); + $message->setSender($this->getUser()); + $entityManager->persist($message); $entityManager->flush(); @@ -57,6 +61,7 @@ final class MessageController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { + $message->setSendingDate(new \DateTime()); $entityManager->flush(); return $this->redirectToRoute('app_message_index', [], Response::HTTP_SEE_OTHER); diff --git a/src/Form/MessageType.php b/src/Form/MessageType.php index b1208d9..a83cdda 100644 --- a/src/Form/MessageType.php +++ b/src/Form/MessageType.php @@ -15,16 +15,10 @@ class MessageType extends AbstractType { $builder ->add('content') - ->add('sendingDate', null, [ - 'widget' => 'single_text', - ]) - ->add('sender', EntityType::class, [ - 'class' => UserApp::class, - 'choice_label' => 'id', - ]) + ->add('receiver', EntityType::class, [ 'class' => UserApp::class, - 'choice_label' => 'id', + 'choice_label' => 'nickname', ]) ; } diff --git a/templates/base.html.twig b/templates/base.html.twig index 0f85cf3..f65d613 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -27,9 +27,9 @@
@@ -60,7 +60,7 @@

Liens utiles

diff --git a/templates/index/index.html.twig b/templates/index/index.html.twig index 8fb84d2..ff61a24 100644 --- a/templates/index/index.html.twig +++ b/templates/index/index.html.twig @@ -41,7 +41,7 @@

Propositions de stages

- Voir tout + Voir tout