Answer the question
In order to leave comments, you need to log in
How to implement a custom insert?
Hello, when implementing the registration form (email, password), having a user table with the fields "id, first_name, last_name, email, password" it is impossible to insert:
public function registrationAction(Request $request)
{
$user = new User();
$form = $this->createForm(new RegistrationType(), $user);
if ($request->getMethod() == 'POST')
{
$form->submit($request);
if ($form->isValid())
{
$em = $this->getDoctrine()->getEntityManager();
$em->persist($user);
$em->flush();
return $this->redirect($this->generateUrl('confirm'));
}
}
return $this->render('NickUserBundle:Signin:registration.html.twig', array
(
'form' => $form->createView(),
));
}
$user->setFirstName('');
$user->setLastName('');
Answer the question
In order to leave comments, you need to log in
doctrine explicitly passes all the parameters that have it, and sets the missing ones to null. I want to know what's the catch?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question