Skip to main content

Overriding FOSUserBundle Forms in Symfony2


It's relatively easy to customize FOSUserBundle behavior by creating your own child bundle, with FOSUserBundle as the parent. Once you've done this, you can provide your own registration and profile forms - as long as you remember all the small steps. This is intended first and foremost as a simple reminder of the steps involved. Code examples follow, but may or may not be exactly what you need. We will assume that you have created an MemberBundle, and declared it a child of FOSUserBundle. We'll demonstrate using the Registration form.

The Checklist

  1. copy the relevant FOSUserBundle twig template and Form class to MemberBundle
  2. ensure that FosUserBundle form type is included in MemberBundle's form class
  3. modify the code of MemberBundle form class
  4. register MemberBundle form as a service
  5. configure the fos_user block in app/config/config.yml