Search code examples
symfonysymfony-formssymfony-2.1user-registration

Symfony2 user registration form example from official docs


I suppose there is something wrong in this example for a simple user registration form in Symfony2.x. In particular, I suppose that there is no setting of the user data. For instance, the setUser() function from Registration class is never used.

Am I right?

If the answer is 'Yes', where should the setUser() function be called?

If the answer is 'No', so why to define that function?


Solution

  • Yes, this function is used. It is used by Symfony when it needs to set the $user property of your registration object, for example when the form is bound. You don´t need to "call" it, it will be called by Symfony when needed.