profile_edition.rst 3.5 KB

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