mardi 29 mars 2016

Symfony : "if" does not work in a twig template

I'm trying to validate the size of an array before print a value, but the if instruction doesn't work. Always pass thought the if.

This is my code:

{% set size = custodian.phoneNumbers|length  %}
{% if size > 3 %}
    {% block phone_number3 %}{{phoneNumbers[2].phoneNumber }}{% endblock %}
{% endif %}

size is equal to 2

I try with this code and does not work as well.

{% set size = true %}
    {% if size == false %}
        {{size}} 
{% endif %}

Please help!!! Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire