Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Symfony 3 - Collection, how to hide widget when ArrayCollection is empty #18804

@achref-riahi

Description

@achref-riahi

Hi,
I use a collection type in a form, my problem is that widgets of the collection are always added to view.

I try to test with twig that the array is empty to hide widgets but that's not fix the problem.

{% if form.taches is defined%}
{% for tache in form.taches %}
    <li>{{ form_widget(tache.libelle) }}</li>
{% endfor %}
{% endif %}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions