I created my own form type at Me\\MyBundle\\Form\\Type\\UserFormRegistrationType
:
namespace Me\MyBundle\Form\Type;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class UserFormRegistrationType extends BaseType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
// all my unique fields
}
public function getName()
{
return 'user_registration';
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('data_class' => 'Me\MyBundle\Entity\User'));
}
}
I have the following in my services.yml:
services:
me_my.registration.form.type:
class: Me\MyBundle\Form\Type\UserFormRegistrationType
arguments: [%fos_user.model.user.class%]
tags:
- { name: form.type, alias: user_registration }
And the following added to my config.yml:
# other config stuff
fos_user:
# database stuff, general config
registration:
form:
type: user_registration
Yet, when I try to access my registration form/page, I get:
Could not load type "user_registration"
Any hint to what I'm obviously missing? It's not a firewall issue. I had one, but tweaking my security.yml fixed it. This is a pure not found error. Very annoying, as I believe I followed the docs to the letter.
You should not use aliases anymore
In your config file :
Before : registration: form: type: user_registration
New : registration: form: type: 'CoreBundle\\Form\\Type\\RegistrationFormType'
In your src/CoreBundle/Form/Type/RegistrationFormType.php: getParent() function should be :
public function getParent()
{
return "FOS\UserBundle\Form\Type\RegistrationFormType";
}
Don't forget the use on the top of the file : use FOS\\UserBundle\\Form\\Type\\RegistrationFormType;
Hi here is the explanation : https://stackoverflow.com/a/53048060/7888453
Official :https://github.com/symfony/symfony/blob/3.4/UPGRADE-3.0.md#form
Take a look at this guys problem and then the solution that he provides to his own question. I went off of his code and modified it to match the names within my files and it worked!
文档拒绝提及/提醒该服务需要在 config.yml 中注册。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.