3

I post a problem here few days ago : FOSUserBundle: embedding the login form and choosing its template

But it's pretty complicated, and I think behind this problem, there is maybe a simple problem of route, so I think it's a good idea to create a parallel topic, delete all the modifications I do, and start with fresh new installation.

So, I install FOSUserBundle, I have a WelcomeBundle, which contains the several pages of my website, and I also create a fresh UserBundle, which only contains the User Entity for FOSUserBundle, nothing else (no override of anything).

In my rsWelcomeBundle, in my index.html.twig, I put this simple code :

{% extends "rsWelcomeBundle::layout.html.twig" %}

{% block title "Page d'accueil" %}

{%  block body %}
    <div class="span6">
        <div class="well">
            <h2>Présentation du jeu</h2>
            <a href="{{ path('rsWelcomeBundle_homepage_inscription') }}" class="btn ">Je m'inscris !</a></p>
        </div>
    </div>
    <div class="span6">
        <div class="well">
            {% render "FOSUserBundle:Security:login" %}
        </div>
    </div>

{% endblock %}

And I always have this error :

An exception has been thrown during the rendering of a template ("No route found for "GET Security:login"") in rsWelcomeBundle:Homepage:index.html.twig at line 1.

If I put this line for the render part it's working.

{% render(controller("FOSUserBundle:Security:login")) %}

But why ?? In the documentation I never see we've to use "render(controller". Why I can't use directly : render "FOSUserBundle:Security:login" ?

In app/config/routing.yml I have :

tuto_welcome:
    resource: "@rsWelcomeBundle/Resources/config/routing.yml"
    prefix:   /

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

In the UserBundle I don't have routing.yml. In the WelcomeBundle I have this in routing.yml :

rsWelcomeBundle_homepage:
    pattern:  /
    defaults: { _controller: "rsWelcomeBundle:Homepage:index" }

It's been two days I try to fix this problem, could you help me ?

Thanks a lot to everyone !

Community
  • 1
  • 1
user2178964
  • 124
  • 6
  • 16
  • 40
  • {% render "FOSUserBundle:Security:login" %} is the Symfony 2.0 way to render a subrequest. {% render(controller("FOSUserBundle:Security:login")) %} is the syntax for 2.1+. Both syntax basically mean the same exact thing. – Hubert Perron Apr 06 '13 at 20:20
  • Thanks a lot ! So if I saw everywhere the first version of this code it's because there is old post ? I don't really understand, I don't find nowhere in the official documentation an exemple of use : render(controller...). And I find that crazy that's the old version is not compatible with 2.1+ Oo ! – user2178964 Apr 06 '13 at 20:38
  • http://symfony.com/doc/2.2/quick_tour/the_view.html#embedding-other-controllers – Hubert Perron Apr 06 '13 at 21:00
  • Ok, how I can choose your answer ? – user2178964 Apr 07 '13 at 09:08
  • Thanks, I will repost my comment as an answer. – Hubert Perron Apr 07 '13 at 15:03

2 Answers2

6

{% render "FOSUserBundle:Security:login" %} is the Symfony 2.0 way to render a subrequest. {{ render(controller("FOSUserBundle:Security:login")) }} is the syntax for 2.1+. Both syntax basically mean the same exact thing.

Documentation about subrequests is here: http://symfony.com/doc/current/quick_tour/the_view.html#embedding-other-controllers

Hubert Perron
  • 3,022
  • 5
  • 34
  • 28
0

Try using {% render url('your url') %} instead.

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130