symfony2 twig form registration included from external template

Be patient is my first question and my english is also poor ;P

Btw... im using fos for my website and all work fine, actually my problem is that i have the "pages" template made with twig and it have, at the bottom, a call to action button that slideDown an hidden div where i want to put my registration form. I setup the hidden div and try to put inside my include:

{% block fos_user_content %}
    {% include "FOSUserBundle:Registration:register_content.html.twig" %}   
{% endblock fos_user_content %}

obviously it dosn't work:

Variable "form" does not exist in kernel.root_dir/Resources/JuliusUserBundle/views/Registration/register_content.html.twig at line 2

probably for some reasons related to routing or firewall or security? anyone have a solutions, suggestions or ideas for that?

thanks and cheers!

Upvotes: 0

Views: 855

Answers (3)

Apparently i found a good solution using Edge Side Includes (ESI) includes that give me also additional benefits in cache control:

<esi:include src="http://localhost:8004/login" />

Upvotes: 0

stevenll
stevenll

Reputation: 1025

If you need to use include then you have to pass the form variable to your included template. Optionally you can render that template also from its corresponding controller. So for the first case you have:

 {% include("FOSUserBundle:Registration:register_content.html.twig") with {'form':form} %} 

Where form here is the variable you pass from your own controller. Your second choice would be to render the FOSUB template like so:

{% render(controller("FOSUserBundle:Registration:register")) %}

Upvotes: 0

kapa89
kapa89

Reputation: 615

As error said, you need to define 'form' variable in your action, or you could try to render FOSUser registration action instead of this.

For example:

{% render(controller(FOSUserBundle:Registration:register")) %}

Upvotes: 1

Related Questions