Remove / Replace the username field with email usi

2019-01-10 00:58发布

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.com/group/symfony2/browse_thread/thread/92ac92eb18b423fe

But then I am stuck with two constraint violations.

Problem is if the user leaves the email address blank, I get two constraint violations:

  • Please enter a username
  • Please enter an email

Is there a way to disable validation for a given field, or a better way to remove a field from the form altogether?

7条回答
叛逆
2楼-- · 2019-01-10 02:00

Have you tried customizing the validation?

To do this, you need to have your own bundle inheriting from the UserBundle, and then copy/adjust Resources/config/validation.xml. Plus, you need to set the validation_groups in the config.yml to your custom validation.

查看更多
登录 后发表回答