Php FOSUserBundle-覆盖表单:无法加载类型“;用户“注册”;

Php FOSUserBundle-覆盖表单:无法加载类型“;用户“注册”;,php,symfony,Php,Symfony,我在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\Option

我在
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'));
    }
}
我有以下服务。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 }
并将以下内容添加到我的config.yml中:

# other config stuff

fos_user:
    # database stuff, general config

    registration:
        form:
            type: user_registration
然而,当我尝试访问我的注册表/页面时,我得到:

无法加载类型“用户注册”


有没有暗示我明显遗漏了什么?这不是防火墙问题。我有一个,但调整了我的安全性。yml修复了它。这是一个纯粹的找不到的错误。非常烦人,因为我相信我严格遵守了文档。

文档拒绝提及/提醒该服务需要在config.yml中注册。

看看这个家伙的问题,然后看看他为自己的问题提供的解决方案。我修改了他的代码,使之与我的文件中的名字相匹配,结果成功了


您不应该再使用别名了

在配置文件中:

之前:

注册:
表格:
类型:用户注册

新的:

注册:
表格:
类型:“CoreBundle\Form\type\RegistrationFormType”

在src/CoreBundle/Form/Type/RegistrationFormType.php中,getParent()函数应为:

public function getParent()
{
    return "FOS\UserBundle\Form\Type\RegistrationFormType";
}
不要忘记文件顶部的用法:

使用FOS\UserBundle\Form\Type\RegistrationFormType;

嗨,这是解释:

官员:

您能详细介绍一下这个解决方案吗?您有解决方案吗?请与我们分享