You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The form name changes to the configured name inside \AcmeBundle\Form\Type\RegistrationType::getBlockPrefix() which is logical (the behavior of Symfony).
But why FOSUserBundle is not using the Type class configured on fos_user.registration.form.type when the form is created ? (createForm method)
Excuse my misunderstanding if I made a mistake but what I understood from the previous file that Form/Factory/FormFactory.php::createForm() is the method that creates the form but when I tried to debug inside this file (I mean inside the __construct() or the createForm() methods) using dump();exit(); I got nothing. Which means that createForm() is not called from this file.
3) Last test
I reproduced the first test and I removed \AcmeBundle\Form\Type\RegistrationType::getBlockPrefix() method so I get another form name (I think it's the default form name generated by Symfony) which is not "fos_user_registration_form".
Conclusion
So I think there is a problem with this line. I'm not an expert of Symfony. But this is what I can conclude after these tests. It's like the custom ReigstrationType is not used because like I showed on the first test: when we hardcode the Form Type in the form creation, everything works fine.
I don't want to keep that form name for some reason.
Symfony FOSUserBundle version 2.1.2:
Hello,
I'm using Symfony 4.3.1 and I followed this documentation to override the default FOSUserBundle and it looks great.
The only problem is about the form name (including form elements name) which is always "fos_user_registration_form"
Example:
I searched how to override that form name "fos_user_registration_form" and I found two ways:
Overriding
\AcmeBundle\Form\Type\RegistrationType::getBlockPrefix()
methodDefining
fos_user.registration.form.name
attribute on theconfig/packages/fos_user.yaml
fileBut none of them works: form name is always "fos_user_registration_form".
So, I was forced to dig into the FOSUserBundle source code and I found something strange:
1) Inside Controller/RegistrationController.php file
When I replace this line:
$form = $this->formFactory->createForm();
With these lines
$form = $this->createForm(\AcmeBundle\Form\Type\RegistrationType::class, $user, array());
The form name changes to the configured name inside
\AcmeBundle\Form\Type\RegistrationType::getBlockPrefix()
which is logical (the behavior of Symfony).But why FOSUserBundle is not using the Type class configured on
fos_user.registration.form.type
when the form is created ? (createForm method)So i digged more inside another file
2) Inside Form/Factory/FormFactory.php file
Excuse my misunderstanding if I made a mistake but what I understood from the previous file that
Form/Factory/FormFactory.php::createForm()
is the method that creates the form but when I tried to debug inside this file (I mean inside the __construct() or the createForm() methods) usingdump();exit();
I got nothing. Which means that createForm() is not called from this file.3) Last test
I reproduced the first test and I removed
\AcmeBundle\Form\Type\RegistrationType::getBlockPrefix()
method so I get another form name (I think it's the default form name generated by Symfony) which is not "fos_user_registration_form".Conclusion
So I think there is a problem with this line. I'm not an expert of Symfony. But this is what I can conclude after these tests. It's like the custom ReigstrationType is not used because like I showed on the first test: when we hardcode the Form Type in the form creation, everything works fine.
I don't want to keep that form name for some reason.
Can anyone help me to find the problem ?
My fos_user.yaml file content:
Thank you for your support
The text was updated successfully, but these errors were encountered: