FOSUserBundle - Overriding forms: could not load type "user_registration"

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

FOSUserBundle overwrite registration but Could not load type error , Your config.yml file should be: fos_user: db_driver: orm firewall_name: main user_class: CoreBundle\Entity\User registration: form: type:� Hi, after composer update my app throws the above named execption when loading register route of FOS UserBundle. Issue is caused by class FOS\\UserBundle\\Form\\Type\\RegistrationFormType. Second param

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!

How to override register form FosUserBundle?

Overrinding registration form: Could not load type <> � Issue #2384 , Hello, I am facing the following issue while overriding the registration form: Well, here are the symptoms: This is the Form Type Overrinding registration form: Could not load type <. And this is the FOSUserBundle config: Second you do not need to override the form type. Since you have added the name field to your entity it will be available in your form automatically via {{ form_widget(myForm.name)} } -> FosUserBundle Doc. However, are your sure you imported your services.xml in your config.yml AND why are you mixing xml and yml? Just stick to one.

The docs declined to mention/remind that the service needs to be registered in config.yml.

Could not load type "XYZ" error when overriding form types � Issue , Could not load type "XYZ" error when overriding form types #383 I've created a bundle to contain my overrides to the FOSUserBundle. In the case of Symfony, there is a very remarkable implementation of this idea in the form of a bundle called FOSUserBundle. This bundle is ideal for designing and implementing user registration and login in a web app. FOSUserBundle allows developer to load and store user credentials from any data source including from configuration and databases.

Overriding Default FOSUserBundle Forms (Symfony Bundles Docs), Overriding Default FOSUserBundle Forms: Overriding a Form Type The using the default registration form you will find that your new name property is not part� SonataUserBundle is not required to use SonataAdminBundle. and it is not an alternative to FOSUserBundle. It is an implementation of the admin classes for the FOSUB entities (and it adds some fields in the user according to Sonata needs)

FOSUserBundle overwrite registration but Could not load type error, FOSUserBundle overwrite registration but Could not load type error. I tried to use <?php // src/CoreBundle/Form/Type/RegistrationFormType.php namespace� The actual most popular bundle is, of course, FOSUserBundle. And it's easy to know why: it gives you a lot of crazy-cool stuff, out-of-the-box: registration, reset password, change password, and edit profile pages. Honestly, it feels like stealing. But guess what? A lot of smart devs don't like FOSUserBundle. How could that be?

Customizing the Forms > FOSUserBundle FTW!, What if we wanted to add our own fields to the registration form? The media could not be loaded, either because the server or network failed or because the format is not Then, I'll use Code->Generate Menu or Command+N to override the buildForm() method. use FOS\UserBundle\Form\Type\ RegistrationFormType as� Symfony3: FOSUserBundle Override Registration Form. idisoft 23 février 2017 à 22:31:15. Bonsoir à tous, Could not load type "security_user_registration"

Comments
  • have you got your solution please share
  • Could you give a little more detail on this solution?