mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
fixes for editing calendar
This commit is contained in:
@@ -137,7 +137,7 @@ class CalendarController extends AbstractController
|
||||
*
|
||||
* @Route("/{_locale}/calendar/calendar/{id}/edit", name="chill_calendar_calendar_edit")
|
||||
*/
|
||||
public function editAction(int $id, Request $request): Response
|
||||
public function editAction(Calendar $entity, Request $request): Response
|
||||
{
|
||||
$view = null;
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
@@ -147,21 +147,14 @@ class CalendarController extends AbstractController
|
||||
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||
$view = '@ChillCalendar/Calendar/editByAccompanyingCourse.html.twig';
|
||||
} elseif ($user instanceof User) {
|
||||
throw new Exception('to analyze');
|
||||
$view = '@ChillCalendar/Calendar/editByUser.html.twig';
|
||||
}
|
||||
|
||||
$entity = $em->getRepository(\Chill\CalendarBundle\Entity\Calendar::class)->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find Calendar entity.');
|
||||
}
|
||||
|
||||
$form = $this->createForm(CalendarType::class, $entity, [
|
||||
'accompanyingPeriod' => $accompanyingPeriod,
|
||||
])->handleRequest($request);
|
||||
$form = $this->createForm(CalendarType::class, $entity);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')->trans('Success : calendar item updated!'));
|
||||
@@ -175,7 +168,7 @@ class CalendarController extends AbstractController
|
||||
$this->addFlash('error', $this->get('translator')->trans('This form contains errors'));
|
||||
}
|
||||
|
||||
$deleteForm = $this->createDeleteForm($id, $user, $accompanyingPeriod);
|
||||
$deleteForm = $this->createDeleteForm($entity->getId(), $user, $accompanyingPeriod);
|
||||
|
||||
if (null === $view) {
|
||||
throw $this->createNotFoundException('Template not found');
|
||||
@@ -188,7 +181,7 @@ class CalendarController extends AbstractController
|
||||
'form' => $form->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
'accompanyingCourse' => $accompanyingPeriod,
|
||||
'user' => $user,
|
||||
// 'user' => $user,
|
||||
'entity_json' => $entity_array,
|
||||
]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user