user17
user17

Reputation: 383

How to check if some variable is present in twig template in symfony2

IN the every template i need to use this ststement

{{ form_stylesheet(form) }}
{{ form_javascript(form) }}

The the template gives error if the page is not haviing any form variable i.e its normal page.

Is there any way that i can check if form is present then load those otherwise not

if (form.present) then
{{ form_stylesheet(form) }}
    {{ form_javascript(form) }}

Upvotes: 0

Views: 650

Answers (1)

Cerad
Cerad

Reputation: 48893

{% if form is defined  %}
    {{ form_stylesheet(form) }}
    {{ form_javascript(form) }}
{% endif %}

http://twig.sensiolabs.org/doc/tags/if.html

Upvotes: 2

Related Questions