createForm(SwitchSectionFormType::class); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $idSection = $form->get('id_section')->getData(); $section = $sectionRepository->find($idSection); $userMerchant = $merchantResolver->getUserMerchant(); if ($section && $userMerchant) { $userMerchant->setCurrentAdminSection($section); $em->update($section); $em->flush(); } } $referer = $request->headers->get('referer'); return $this->redirect($referer); } }