security->isGranted('ROLE_USER')) { throw new AccessDeniedHttpException(); } $user = $this->security->getUser(); $editForm = $this->createPhonenumberEditForm($user); $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $phonenumber = $editForm->get('phonenumber')->getData(); $user->setPhonenumber($phonenumber); $this->managerRegistry->getManager()->flush(); $this->addFlash('success', $this->translator->trans('user.profile.Phonenumber successfully updated!')); return $this->redirectToRoute('chill_main_user_profile'); } return $this->render('@ChillMain/User/profile.html.twig', [ 'user' => $user, 'form' => $editForm->createView(), ]); } private function createPhonenumberEditForm(UserInterface $user): FormInterface { return $this->createForm( UserPhonenumberType::class, $user, ) ->add('submit', SubmitType::class, ['label' => $this->translator->trans('Save')]); } }