简体   繁体   中英

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 ie 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) }}
{% if form is defined  %}
    {{ form_stylesheet(form) }}
    {{ form_javascript(form) }}
{% endif %}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM