Pat*_*ick 1 null entity symfony-forms symfony fosuserbundle
Commuity,
我使用FosUserBundle,我的用户名有问题.
在我的页面上,您只需要一封电子邮件和一个密码.=>你可以使用用户名!(因为那样,我无法使用setUsername($ email)^^覆盖实体中的setEmail()函数
如果我在我的配置中使用它,我会收到以下错误.
fos_user:
registration:
form:
validation_groups: [AppRegistration]
Run Code Online (Sandbox Code Playgroud)
错误:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'username' cannot be null
Run Code Online (Sandbox Code Playgroud)
我能做什么?
先感谢您!
# app/config/security.yml
security:
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
Run Code Online (Sandbox Code Playgroud)
更改您的security.yml以使fosuserbundle接受电子邮件作为用户名,从用户名或电子邮件记录,并起诉您覆盖您的setUsername方法,因为用户名不能为空.例如
public function setEmail($email){
parent::setEmail($email);
parent::setUsername($email);
}
Run Code Online (Sandbox Code Playgroud)