Answer the question
In order to leave comments, you need to log in
When editing a username, if the new name is taken, an error message is displayed, and... and does the current user's name change in the site header?
In symfony3 I make a user profile, authorization occurs by email, username is just a unique username.
public function profileAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$user = $em->getRepository('UserBundle:User')->findOneByToken($this->getUser()->getToken());
$form = $this->createForm(UserProfileType::class, $user);
$form->handleRequest($request);
if ($form->isValid()) {
$em->flush();
$this->addFlash('success', self::MSG_SUCCESS_EDIT);
}
return [
'form' => $form->createView()
];
}
$form = $this->createForm(UserProfileType::class, clone $user);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question