After creating registration form in that way: https://symfony.com/doc/current/doctrine/registration_form.html There is a problem with creating account. In previous version I did it in the same way, and there weren't wny problem. I am not sure is it a bug or I do something in wrong way. Form is still invalid. In Profiler->Validation I can see a call: data.password This value should not be null.
I tried to remove data parameter from form buildier and remove Options Resolver and then works, but I know it's not a correct solution.
Removed from RegistrationFormType.php:
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
Changed in RegistrationController.php:
public function register(Request $request, UserPasswordEncoderInterface $passwordEncoder, GuardAuthenticatorHandler $guardHandler, AppAuthenticator $authenticator): Response
{
$user = new User();
$form = $this->createForm(RegistrationFormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$user->setEmail($form->get('email')->getData());
$user->setPassword(
$passwordEncoder->encodePassword(
$user,
$form->get('plainPassword')->getData()
)
);
Can you help me with correct solution of this problem?