Symfony2: How to build multiple registration forms with FOSUserBundle
fosuserbundle, symfony
Solution
FOSUserBundle is not to provide authentication of users but to manage users. The bundle provides you a better structure to manage users for your application. If you take a look at the code you will find controllers that are used for the default registration and other user activities.
Ideally you would want to write your own controller and make use of the bundle to only store and retrieve users. This is especially required when you want to manage multiple registration/login forms.
Things would seem clearer once you start to consider FOSUserBundle only to manage users and not to authenticate/register them.
You might also want to look at https://github.com/sonata-project/SonataUserBundle, which provides integration between SonataAdminBundle and FOSUserBundle.
Problem
I'm absolutely new to Symfony2 but already in love with this framework. I'm having a project that requires to have 3 different user types. One will be super admin, other two will be a regular users but with different profile layouts. Different layouts for profile means registration form for those two user types must have different form fields and different layouts in the application after registration. I think I've got the idea (don't know if that will be OK later) how to manage users after registration. But for now I don't understand how to build two different registration forms that will be extended from FOSUserBundle. As far as I understand FOSUB have only one point in the configuration where registration is set up and cannot have multiple "registration:" In the config.yml I have: ``` fos_user: db_driver: orm firewall_name: main user_class: Company\UserBundle\Entity\User registration: confirmation: { enabled: true } ``` security.yml: ``` security: encoders: FOS\UserBundle\Model\UserInterface: sha512 main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider logout: true anonymous: true ``` My idea is to create three different bundles that extends FOSUB, but documentation says that only one bundle can declare FOSUB as parent. Another option (from documentation) is to extend ContainerAware implementing all original methods. But even in this case, I don't get it how I have to configure app/config/{config|security|routing}.yml to have for instance /register_employee, /register_manager links that will use FOSUB and my custom forms? Please point me to right direction. Thanks.