Feature request - make the email and emailCanonical fields optional
Hi!
I am creating a web app for a health care research project. I really don't want the email adresses of the users stored. And as of now, there is no easy way of removing it without editing the bundle. for instance php app/console fos:user:create someone requires it even though I do @ORM\AttributeOverrides on the fields and set them to nullable and removes the unique constraint when extending the User model class.
This is a stackoverflow question showing my little struggle: http://stackoverflow.com/questions/15162142/symfony2-fosuserbundle-simple-way-to-get-rid-of-the-email-fields-in-user/15164191#15164191
Just redefine the complete doctrine mapping and all validators...
fos:user:create is meant as an utility tool to help. It does not work anyway when you are adding more required fields. For the doctrine mapping, using @ORM\AttributeOverrides is indeed the way to go.
if you really don't need the addresses... and you are not using that field for anything else...AAAND you don't want to redefine everything just for that.....just override the setUsername($username) function in your entity and do something like this:
public function setUsername($username) {
$this->username = $username; // Careful calling $this->setUsername() here to avoid loop..
$this->setEmail($username."@somethingliketheurloftheapp.com");
}
That will simply populate that email address field in the background.. but again that is if you are not using it :).. later on if you need it you can simply run a super query to clean that field