Question

In a continuing effort to incorporate the multi-user bundle in a project I get

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_content.html.twig at line 3.

I've been through the documentation several times and have not yet seen where in the following configuration I've made an error. The above error occurs when, in dev, I go to /register/staff. Can't figure out how we get to the original fos registration.

Edit: stack trace appended below, showing transition to FOSUserBundle

config.yml

fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: Vol\VolBundle\Entity\Person
#    registration:
#        form:
#            type: vol_user_registration
    service:
        user_manager: pugx_user_manager

pugx_multi_user:
  users:
    staff:
        entity: 
          class: Vol\VolBundle\Entity\Staff
#          factory: 
        registration:
          form: 
            type: Vol\VolBundle\Form\RegistrationStaffFormType
            name: fos_user_registration_form
            validation_groups:  [Registration, Default]
          template: VolVolBundle:Registration:staff.form.html.twig
        profile:
          form:
            type: Vol\VolBundle\Form\ProfileStaffFormType
            name: fos_user_profile_form
            validation_groups:  [Profile, Default] 
    volunteer:
        entity: 
          class: Vol\VolBundle\Entity\Volunteer
        registration:
          form: 
            type: Vol\VolBundle\Form\RegistrationVolunteerFormType
          template: VolVolBundle:Registration:volunteer.form.html.twig
        profile:
          form: 
            type: Vol\VolBundle\Form\ProfileVolunteerFormType

routing.yml:

fos_user_security:
    resource: "@FOSUserBundle/Resources/config/routing/security.xml"

fos_user_profile:
    resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
    prefix: /profile

#rem'd for PUGX multi-user bundle
#fos_user_register:
#    resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
#    prefix: /register

fos_user_resetting:
    resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
    prefix: /resetting

fos_user_change_password:
    resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
    prefix: /profile

##add following for PUGX multi-user bundle
staff_registration:
    pattern:  /register/staff
    defaults: { _controller: VolVolBundle:RegistrationStaff:register }

volunteer_registration:
    pattern:  /register/volunteer
    defaults: { _controller: VolVolBundle:RegistrationVolunteer:register }

controller:

class RegistrationStaffController extends Controller
{
    /**
     * @return type
     */
    public function registerAction()
    {
        return $this->container
                    ->get('pugx_multi_user.registration_manager')
                    ->register('Vol\VolBundle\Entity\Staff');
    }
}

By request, the templates staff.form.html.twig & staff_register_content.html.twig:

//staff.form.html.twig
{% extends 'VolVolBundle:Default:layout.html.twig' %}
{% block body %}
Staff Registration Form
{% block fos_user_content %}
{% include 'VolVolBundle:Registration:staff_register_content.html.twig' %}
{% endblock fos_user_content %}
{% endblock %}

//staff_register_content.html.twig
{% trans_default_domain 'FOSUserBundle' %}

<form action="{{ path('staff_registration') }}" {{ form_enctype(form) }} method="POST">
    {{ form_widget(form) }}
    <div>
        <input type="submit" value="{{ 'registration.submit'|trans }}" />
    </div>
</form>

default layout:

<!DOCTYPE html >
<head>
{% stylesheets '@VolVolBundle/Resources/public/css/*' filter='cssrewrite' %}
    <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}</head>
<body class="background" >
        {% block body %}

        {% endblock %}
</body>

stack trace

at Symfony\Bundle\TwigBundle\TwigEngine->renderResponse('FOSUserBundle:Registration:register.html.twig', array('form' => object(FormView)))
    in G:\Documents\workspace\volunteer\vendor\friendsofsymfony\user-bundle\FOS\UserBundle\Controller\RegistrationController.php line 78

at FOS\UserBundle\Controller\RegistrationController->registerAction(object(Request))
    in G:\Documents\workspace\volunteer\vendor\pugx\multi-user-bundle\PUGX\MultiUserBundle\Controller\RegistrationManager.php line 63

at PUGX\MultiUserBundle\Controller\RegistrationManager->register('Vol\VolBundle\Entity\Staff')
    in G:\Documents\workspace\volunteer\src\Vol\VolBundle\Controller\RegistrationStaffController.php line 25

at Vol\VolBundle\Controller\RegistrationStaffController->registerAction()
    in  line 

at call_user_func_array(array(object(RegistrationStaffController), 'registerAction'), array())
    in G:\Documents\workspace\volunteer\app\bootstrap.php.cache line 2911

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
    in G:\Documents\workspace\volunteer\app\bootstrap.php.cache line 2883

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
    in G:\Documents\workspace\volunteer\app\bootstrap.php.cache line 3022

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
    in G:\Documents\workspace\volunteer\app\bootstrap.php.cache line 2303

at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
    in G:\Documents\workspace\volunteer\web\app_dev.php line 28
Was it helpful?

Solution 2

A misunderstanding of the bundle's instructions. A revised routing.yml, where fos_user_register is NOT commented out!

routing.yml

fos_user_security:
    resource: "@FOSUserBundle/Resources/config/routing/security.xml"

fos_user_profile:
    resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
    prefix: /profile

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

fos_user_resetting:
    resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
    prefix: /resetting

fos_user_change_password:
    resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
    prefix: /profile

##add following for PUGX multi-user bundle
staff_registration:
    pattern:  /register/staff
    defaults: { _controller: VolVolBundle:RegistrationStaff:register }

volunteer_registration:
    pattern:  /register/volunteer
    defaults: { _controller: VolVolBundle:RegistrationVolunteer:register }

OTHER TIPS

Does 'VolVolBundle:Default:layout.html.twig' contain a registration link?

fos_user_registration_registerroute is being called somewhere in one of your templates.

Looking at the above, I'd guess that your VolVolBundle:Default:layout.html.twig doesn't have a {% block body %} block in it?

If VolVolBundle:Default:layout.html.twig is a copy of the FOSUserBunde::layout.html.twig template, it wouldn't, which means your {% block fos_user_content %} is most likely not overwriting the layout template and (somehow) the FOSUserBundle defaults are being used.

Are you able to post your VolVolBundle:Default:layout.html.twig template as well?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top