1

I'm using the sfDoctrineApplyPlugin and the registration 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.

Peter Hough
  • 560
  • 4
  • 17

1 Answers1

3

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);
  }
}
Community
  • 1
  • 1
Luis Chanferoni
  • 336
  • 2
  • 4
  • Thanks for you're answer luichanfe. I understand how to generate a username based on the email address. The question i'm asking is if this is the best way. That username could exist so i'll have to do extra checking for that too. Have you used this method successfully? Maybe overwriting the notnull is the better method? – Peter Hough Apr 04 '11 at 14:08
  • I'm sorry, I've never used this method exactly. One of the solution would be as you say, overwrite the notnull, and another would be to save the email on the username field. – Luis Chanferoni Apr 07 '11 at 16:01
  • OK, I'll probably look at the notnull method. Thanks for your help – Peter Hough Apr 08 '11 at 14:00