No Username? sfDoctrineGuard/Apply
I'm using the sfDoctrineApplyPlugin and the reg开发者_Python百科istration form requires a username - what's the best way of removing this field?
As the sfDoctrineGuardPlugin allows login via username or email address I'd like my application to use the email address only to identify users. Making specifying a username in registration surplus to requirements.
Would I need to hide this field from the view and then on submit generate a username that's stored to satisfy the plugins but the user never needs to see or use? What's the best way of generating this? The bit before the @ in the email address?
Many thanks for any help in advance.
I think you could start here Symfony: how would you reverse the "notnull:true" in a schema of a plugin?. And you could do this:
class sfGuardUserForm extends PluginsfGuardUserForm
{
protected function doUpdateObject($values)
{
$email_array = explode($values['email']);
$this->getObject()->set('username', $email_array[0]);
parent::doUpdateObject($values);
}
}
精彩评论