From 8b2a8544b8693cc50f2ff9c4d74f35b1bfe0eba5 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 21:58:56 +0100 Subject: [PATCH] form type and controller, wip --- .../AccompanyingCourseController.php | 22 +++++++++-- .../Form/AccompanyingCourseCommentType.php | 39 +++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 3de0e30f4..dccf780d8 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Controller; use Chill\ActivityBundle\Entity\Activity; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Form\AccompanyingCourseCommentType; use Chill\PersonBundle\Form\AccompanyingCourseType; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; @@ -217,18 +218,31 @@ class AccompanyingCourseController extends Controller ]); } - - /** * Comments page of Accompanying Course section. * - * @Route("/{_locale}/parcours/{accompanying_period_id}/comment", name="chill_person_accompanying_period_comment_list") + * @Route("/{_locale}/parcours/{accompanying_period_id}/comments", name="chill_person_accompanying_period_comment_list") * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ - public function commentAction(AccompanyingPeriod $accompanyingCourse): Response + public function commentAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response { + +/* + $form = $this->createForm(AccompanyingCourseCommentType::class, $comment, []); + + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + + $em = $this->getDoctrine()->getManager(); + $em->persist($comment); + $em->flush(); + + } +*/ return $this->render('@ChillPerson/AccompanyingCourse/comment_list.html.twig', [ 'accompanyingCourse' => $accompanyingCourse, +// 'form' => $form->createView() ]); } diff --git a/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php b/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php new file mode 100644 index 000000000..5d580d325 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php @@ -0,0 +1,39 @@ +add('content', ChillTextareaType::class, []); + } + + /** + * @param OptionsResolver $resolver + * @return void + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefault('class', Comment::class); + } +}