I only want to have email as mode of login, I don\'t want to have username. Is it possible with symfony2/symfony3 and FOSUserbundle?
I read here http://groups.google
As Michael points out, this can be solved with a custom validation group. For example:
fos_user:
db_driver: orm
firewall_name: main
user_class: App\UserBundle\Entity\User
registration:
form:
type: app_user_registration
validation_groups: [AppRegistration]
Then in your entity (as defined by user_class: App\UserBundle\Entity\User
) you can use the AppRegistration group:
class User extends BaseUser {
/**
* Override $email so that we can apply custom validation.
*
* @Assert\NotBlank(groups={"AppRegistration"})
* @Assert\MaxLength(limit="255", message="Please abbreviate.", groups={"AppRegistration"})
* @Assert\Email(groups={"AppRegistration"})
*/
protected $email;
...
This is what I ended up doing after posting that reply to the Symfony2 thread.
See http://symfony.com/doc/2.0/book/validation.html#validation-groups for full details.