createForm(SwitchSectionFormType::class); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { // valeur par défaut de $section : Tout afficher $section = null; $idSection = $form->get('id_section')->getData(); $userMerchant = $merchantResolver->getUserMerchant(); if($userMerchant) { if($idSection) { $section = $sectionContainer->getStore()->getOneById($idSection); } $userMerchant->setCurrentAdminSection($section); $entityManager->update($userMerchant); $entityManager->flush(); } } $referer = $request->headers->get('referer'); return $this->redirect($referer); } }