From c3b25b6eeb5960e566b6b0a68e9357c72c277c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 18 Jun 2020 16:41:06 +0200 Subject: [PATCH] fix redirection on person view: add a `person_id` to every page redirected. After a form was submitted, the CRUD controller redirect to page without a person_id. Now, the EntityPersonCRUDController redirects to a page **with** a person_id. --- CHANGELOG.md | 2 ++ CRUD/Controller/EntityPersonCRUDController.php | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01837a378..8f40d0ad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,4 +103,6 @@ Master branch - [CRUD] add step delete - [CRUD] improve index view in person CRUD - [CRUD] filter by basis on person by default in EntityPersonCRUDController +- [CRUD] override relevant part of the main CRUD template +- [CRUD] fix redirection on person view: add a `person_id` to every page redirected. diff --git a/CRUD/Controller/EntityPersonCRUDController.php b/CRUD/Controller/EntityPersonCRUDController.php index f729f8b02..54ae006ee 100644 --- a/CRUD/Controller/EntityPersonCRUDController.php +++ b/CRUD/Controller/EntityPersonCRUDController.php @@ -117,15 +117,21 @@ class EntityPersonCRUDController extends CRUDController switch ($next) { case "save-and-close": return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_index', [ - 'person_id' => $entity->getPerson()->getId() + 'person_id' => $this->getPerson($request)->getId() ]); case "save-and-new": return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_new', [ - 'person_id' => $entity->getPerson()->getId() + 'person_id' => $this->getPerson($request)->getId() + ]); + case "new": + return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_view', [ + 'id' => $entity->getId(), + 'person_id' => $this->getPerson($request)->getId() ]); default: return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_view', [ - 'id' => $entity->getId() + 'id' => $entity->getId(), + 'person_id' => $this->getPerson($request)->getId() ]); } }