Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6319073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:44:24+00:00 2026-05-24T15:44:24+00:00

Hy guys, I decided to use FOSUserBundle for handling user authentication in my application.

  • 0

Hy guys,

I decided to use FOSUserBundle for handling user authentication in my application.
In my application, companies can register their details (name, address, etc).

So I decided to create an entity called Company to hold the company related data and an entity called User to keep the user data from FOSUserBundle separately.

I started to override the default registration form as it is described in the documentation Overriding Default FOSUserBundle Forms, but the problem is that I can’t add my fields from Company to the form, it always try to access from the User entity (propably because that one is related to FOSUserBundle).

Is there any way to put the Company entity fields in the FOSUser registration form?

I don’t want to mess up the data model by using the Company as the base entity for FOSUser and adding to it all the fields (username, email, password, etc).

Best regards,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:44:26+00:00Added an answer on May 24, 2026 at 3:44 pm

    Semantically speaking, a User doesn’t have to be a person, so I see no reason for a company being your application’s user. I also see no reason for having two separate tables in your database.

    I would create a separate Company class, which extends the user class:

    namespace Acme\Bundle\AcmeBundle\Entity;
    
    use FOS\UserBundle\Entity\User;
    
    class Company extends User
    {
        // Your company related fields and related getters/setters go here.
    }
    

    Then override the user class from your configuration (e.g in app/config/config.yml):

    fos_user:
        user_class: Acme\Bundle\AcmeBundle\Entity\Company
    

    Now the UserBundle knows which class to use as the User. After setting up your custom class you can override the RegistrationFormType to include your custom fields.

    If, however, you still wish to use two separate entities in your application, I suggest you connect them via a One-To-One relationship and then embed your Company entity to RegistrationFormType by following the docs about embedding a single object to a form.

    Reference: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/1.2.0/Resources/doc/overriding_forms.md

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys, can someone give me a brief run through of how to change the
Guys, I've came across this problem I can't resolve myselg, I'm pretty sure I
Guys, what is function called after my class loaded, where i can call self
Possible Duplicate: Interface vs Abstract Class (general OO) Hi guys, I decided to dig
I'm just starting a project and decided to use Spring with Appengine. I'm now
I just started working with Drupal for a while and decided to use this
Apple recently decided to allow developers to use this UIGetScreenImage private API. I have
I'm conflicted. you guys decide if this should migrate to SU or not. I
Guys, I’ve been writing code for 15+ years, but managed to avoid Web Development
Guys, I am using SQL Server 2000 and executing the sp_columns stored procedure to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.