在 sfDoctrineGuardPlugin 中设置用户名等于 email_address
在表sf_guard_user
中,需要email_address
和username
,但我想使用电子邮件作为username
,
所以,我正在考虑从表单中删除此字段之一,但由于需要,我总是收到错误,并且我正在尝试设置 username
= email_address 或反之亦然,我在操作、表单和模型中尝试过,但没有成功......
认为在 sfGuardUser
模型中编写一个名为 getUsername( )
并返回电子邮件就足够了,但是不行……
这可能吗? 我该怎么办?
谢谢
in the table sf_guard_user
, the email_address
and username
are requiered, but i want to use the email as username
so, i'm thinking to remove one of this field from the form, but as it are required, i always get the error, and i'm trying to set the username
= email_address
or vice versa, i've tried in the action, form, and model, but no success....
thought that writing a function in the sfGuardUser
model with the name getUsername()
and returning the email was enough, but no........
is this possible??
how can i do it??
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然这是可能的。您甚至不必搞乱架构。只需将电子邮件存储在用户名和电子邮件地址中即可。
Of cause it is possible. You don't even have to mess with schema. Just store email in both username and email_address.
覆盖 Object::save() 函数中的用户名字段是更好的方法 - 以便它处理所有表单。
在您的表单中,您可以覆盖用户名小部件的验证器。如果需要,您还可以隐藏该小部件。
和
Overriding username field in the Object::save() function is much better way - so that it handles all forms.
In you forms, you override the validator for username widget. You can also hide the widget if you want.
and