From 80f18f7fc8f250918de61a0d7ab280d9b555473b 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 ++-------- 2 files changed, 7 insertions(+), 8 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', ]) ; }