本文介绍了Symfony2:如何使FOSUserBundle用户的用户名唯一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有自己的User类,该类继承了FOS\UserBundle\Entity\User.另外,我编写了自己的注册例程.现在,我有一个问题,即表单不能确保用户名是唯一的.我总是得到:

I have my own User Class, which inherits FOS\UserBundle\Entity\User. Additionally I wrote my own registration routine. Now I have the problem that the form does not make sure that the username is unique. I always get:

我尝试按照文档中的说明添加@UniqueEntity("email")注释 1 ,但没有任何效果.

I tried adding the @UniqueEntity("email") annotation as stated in the documentation1, but without any effect.

有人知道怎么了吗?

推荐答案

约束已存在于FOS捆绑包中.您可能需要将表单上的validation_groups选项设置为array('Registration').

The constraint exists in the FOS bundle already. You probably need to set the validation_groups option on your form to array('Registration').

这篇关于Symfony2:如何使FOSUserBundle用户的用户名唯一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:20