Whole error is missiong namespace Symfony\Component\Form which is replaced with 3 dots, due to title maximum characters.
So, I am following the steps, that are presented in the docs and I'm unable to find source of the error I'm getting. If anyone could help, I'd greatly appreciate it.
Here is the method from my AuthController
/**
* @Route("/register", name="registrationPage")
*/
public function showRegistrationPage(Request $request)
{
return $this->render('auth/register.html.twig', [
'register_form' => $this->createForm(RegisterType::class, (new UserInformation()))
]);
}
And here is the method, where I declare the form
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('firstname', TextType::class, ['attr' => ['class' => 'form-control']])
->add('secondname', TextType::class, ['attr' => ['class' => 'form-control']])
->add('email', EmailType::class, ['attr' => ['class' => 'form-control']])
->add('password', PasswordType::class, ['attr' => ['class' => 'form-control']])
->add('password_confirmation', PasswordType::class, [
'label' => 'Confirm Password',
'attr' => ['class' => 'form-control'],
'mapped' =>false
])
->add('Register', SubmitType::class, ['attr' => ['class' => 'btn btn-primary']]);
}
/**
* @Route("/register", name="registrationPage")
*/
public function showRegistrationPage(Request $request)
{
$form = $this->createForm(RegisterType::class, (new UserInformation()));
return $this->render('auth/register.html.twig', [
'register_form' => $form->createView()
]);
}
http://symfony.com/doc/current/forms.html#building-the-form
the missing part was createView() method
/**
* @Route("/register", name="registrationPage")
*/
public function showRegistrationPage(Request $request)
{
return $this->render('auth/register.html.twig', [
'register_form' => $this->createForm(RegisterType::class, (new UserInformation()))->createView()
]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With