PUGXMultiUserBundle icon indicating copy to clipboard operation
PUGXMultiUserBundle copied to clipboard

registration template

Open ghost opened this issue 12 years ago • 7 comments

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]

ghost avatar Apr 16 '13 12:04 ghost

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.

gregory90 avatar Apr 22 '13 14:04 gregory90

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">

SebFourault avatar May 28 '13 16:05 SebFourault

which branch are you using?

leopro avatar Jun 05 '13 16:06 leopro

I'm getting the same issue

cve avatar Nov 02 '13 13:11 cve

please, which branch are you using?

leopro avatar Nov 13 '13 11:11 leopro

I'm using

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

from doc

cve avatar Nov 13 '13 16:11 cve

@krustydaclown Where can I found the rout for FOSUserBundle?

napestershine avatar Mar 16 '16 12:03 napestershine