PUGX / PUGXMultiUserBundle

An extension for FOSUserBundle to handle users of different types. Compatible with Doctrine ORM.
163 stars 96 forks source link

registration template #18

Open beliveyourdream opened 11 years ago

beliveyourdream commented 11 years ago

After following the steps in the documentation whenever i go to the /register/client route i get this :

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "fos_user_registration_register" as such route does not exist.") in FOSUserBundle:Registration:register.html.twig at line 4.

The only way i could solve this was by uncommenting the registration route of FOSUB but i don't think it should be like this.

Here is my config for the client type user:

pugx_multi_user:
  users:
      client_user:
          entity:
              class: Acme\UserBundle\Entity\ClientUser
          registration:
              form:
                  type: Acme\UserBundle\Form\Type\ClientRegistrationFormType
                  name: fos_user_registration_form
                  validation_groups:  [Registration, Default]
              template: AcmeUserBundle:Registration:client.form.html.twig
          profile:
              form:
                  type: Acme\UserBundle\Form\Type\ClientProfileFormType
                  name: fos_user_profile_form
                  validation_groups:  [Profile, Default]
gregory90 commented 11 years ago

One way to solve this would be overriding register.html.twig template from FOSUB. ( https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_templates.md ) Then you can delete registration route of FOSUB.

Still, would've been better if there was some cleaner way to do this.

SebFourault commented 11 years ago

Yes it's not explained in the user guide (that's why it generate an error when you suppr the route)

When you delete the route :

fos_user_register:
    resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
    prefix: /register

You have to recreate the routes present in FOSUserBundle/Resources/config/routing/registration.xml so that the registration works. (so basically copy/past them into the global rooting.yml)

Then you have to separate the unique registration route (registration_register) into 2 routes (one leading to the unerone registration controller and one for the unertwo registration controller)

For example :

user_one_registration_register:
    pattern:  /register/userone
    defaults: { _controller: MyBundleUserBundle:RegistrationUserOne:register }

user_two_registration_register:
    pattern:  /register/usertwo
    defaults: { _controller: MyBundleUserBundle:RegistrationUserTwo:register }

Then you have to create in YourBundle a view to override the fosuserbundle one : mybundle/ressources/views/registration/register_content.html.twig (in which you choose the target of the form : for user one, the target should redirect to the route user_one_registration_register and the same for usertwo). You have to find a way to know which target your are going tu put in your form. for example :

<form action="

{% if app.request.attributes.get('_route') == 'user_one_registration' %}
{{ path('user_one_registration_register') }}
{% endif %}

{% if app.request.attributes.get('_route') == 'user_two_registration' %}
{{ path('user_two_registration_register') }}
{% endif %}

" 
{{ form_enctype(form) }} method="POST" class="fos_user_registration_register">
leopro commented 11 years ago

which branch are you using?

cve commented 11 years ago

I'm getting the same issue

leopro commented 11 years ago

please, which branch are you using?

cve commented 11 years ago

I'm using

"pugx/multi-user-bundle": "3.0.*@dev"

from doc

napestershine commented 8 years ago

@krustydaclown Where can I found the rout for FOSUserBundle?