2

After updating symfony2 with the dependencies to 2.8 I get the following error message when trying to override the sonata user bundle registration form:

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

If I switch back to Symfony 2.7 everything works again.

My services.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 }

In my controller the following line triggers the error:

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

Unfortunately I couldn't find any resources on this subject (i.e. if there are any changes in overriding the registration form since the latest version)

dominikweber
  • 622
  • 1
  • 9
  • 23

1 Answers1

2

Ok, this isn't a bug, but a new feature. You have to use the build() and boot() methods in your bundle to register your FormType via FormHelper::registerFormTypeMapping.

dominikweber
  • 622
  • 1
  • 9
  • 23
  • Can you show a code example? I'm having the same problem and don't understand what you mean exactly! thanks – Etienne Noël Jan 25 '16 at 19:52
  • 1
    You can find a code sample here: https://sonata-project.org/bundles/core/master/doc/reference/form_types.html#symfony3-supports It's important to include your bundle AFTER the bundle that contains the form type you want to override (in your AppKernel). – dominikweber Jan 26 '16 at 14:01