Reputation: 9262
I'm working on a project that uses SF 2.0 and the FOSUserBundle.
The default user class has both username and email fields that are required. I would much rather use email for both. Has anyone implemented this before, or does anyone have a suggestion for how to do this properly?
I did see one answer elsewhere, to override the class & set username = email in the creation function, and then override the form to get rid of the username field. This seems like a fairly easy workaround, but a bit of a hack,
Upvotes: 1
Views: 285
Reputation: 6237
The workaround you are talking about is definitely not an hack. If you think about that you are just using classes inheritance and overriding some methods (the constructor or even better the setUsername and setEmail methods) to adapt the logic of a generic class to your needs. This is pretty much conforming to the open/close principle.
Moreover I don't think that there is another simple way to achieve your goal; IMO any other way would probably be far more hacky!
Upvotes: 3