profile_edition.rst 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. Profile Edition
  2. ===============
  3. The FOS User Bundle already has a form to edit a "profile", the form allows to
  4. edit login and password information. However the Sonata User Bundle introduces new
  5. fields inside the user table. In order to have a clear separation between authentication
  6. information and profile information, a specific form has been created.
  7. In Sonata User Bundle, the "profile" term is related to user information and the
  8. "authentication" term is related to the user's login and password. This separation
  9. is also useful if the credential system is not the default one provided by the solution
  10. but still want to store user's metadata.
  11. So if you have configured a specific 'profile' form inside the FOS User Bundle, you actually
  12. edit the authentication form inside the Sonata User Bundle (if you enable the feature).
  13. This is also the reason why the configuration between FOS User Bundle and Sonata User Bundle
  14. might look the same, however the final purpose is not the same.
  15. Sonata Profile Configuration
  16. ----------------------------
  17. You are not forced to use the current configuration as everything can be done in the FOS User Bundle
  18. from the original ``profile`` form. Now, if you like to quickly build a user profile with more fields
  19. than the default one, please continue reading ...
  20. First, the ``fos_user`` section need to be altered to set the valid ``Authentication`` group.
  21. .. code-block:: yaml
  22. fos_user:
  23. db_driver: orm # can be orm or odm
  24. firewall_name: main
  25. user_class: Application\Sonata\UserBundle\Entity\User
  26. group:
  27. group_class: Application\Sonata\UserBundle\Entity\Group
  28. profile: # Authentication Form
  29. form:
  30. type: fos_user_profile
  31. handler: fos_user.profile.form.handler.default
  32. name: fos_user_profile_form
  33. validation_groups: [Authentication] # Please note : this is not the default value
  34. Next, you need to configure the ``profile`` section of ``sonata_user``:
  35. .. code-block:: yaml
  36. sonata_user:
  37. security_acl: false
  38. class:
  39. user: Application\Sonata\UserBundle\Entity\User
  40. group: Application\Sonata\UserBundle\Entity\Group
  41. profile: # Profile Form (firstname, lastname, etc ...)
  42. form:
  43. type: sonata_user_profile
  44. handler: sonata.user.profile.form.handler.default
  45. name: sonata_user_profile_form
  46. validation_groups: [Profile]
  47. You can also only override the service parameter to use your own php class, for example to override or
  48. disable some fields. So you don't need to redefine the hole service definition.
  49. And finally, just change the default ``profile`` routing. Actually it is the only configuration you need
  50. to define to make it works.
  51. .. code-block:: yaml
  52. # replace these 3 lines :
  53. fos_user_profile:
  54. resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
  55. prefix: /profile
  56. # by those lines :
  57. sonata_user_profile:
  58. resource: "@SonataUserBundle/Resources/config/routing/profile.xml"
  59. prefix: /profile
  60. Actions
  61. -------
  62. The Sonata User Bundle comes with 3 profiles actions :
  63. - show : show the current user
  64. - edit profile : edit the profile information (lastname, firstname, etc ...)
  65. - edit authentication : edit the profile authentication information (login, password)