2

在将 symfony2 与依赖项更新到 2.8 后,我在尝试覆盖奏鸣曲用户捆绑注册表单时收到以下错误消息:

The field type "Sonata\UserBundle\Form\Type\RegistrationFormType" is not registered with the service container.

如果我切换回 Symfony 2.7,一切都会再次运行。

我的服务.yml:

sonata.user.registration.form.type:
    class: My\Bundle\Form\Type\RegistrationFormType
    arguments: [ "%fos_user.model.user.class%" , "@service_container"]
    tags:
        - { name: form.type, alias: sonata_user_registration }

在我的控制器中,以下行触发错误:

$form = $this->container->get( 'sonata.user.registration.form' );

不幸的是,我找不到有关此主题的任何资源(即,自最新版本以来是否在覆盖注册表单方面有任何更改)

4

1 回答 1

2

好的,这不是一个错误,而是一个新功能。您必须使用包中的 build() 和 boot() 方法通过 FormHelper::registerFormTypeMapping 注册您的 FormType。

于 2015-12-02T10:18:21.907 回答