8000 Symfony 3 - Collection, how to hide widget when ArrayCollection is empty · Issue #18804 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
achref-riahi opened this issue May 17, 2016 · 5 comments
Open

Comments

@achref-riahi
Copy link
achref-riahi commented May 17, 2016

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 %}
@mccullagh
Copy link
Contributor

@4Dr3N4L1N3 can you provide the code of your form?

From the example maybe that helps you already:

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

@bhavin-nakrani
Copy link
Contributor

Explicitly mark the field as rendered:

{% do form.taches.setRendered %}

@HeahDude
Copy link
Contributor

Will be fixed by #17609, but I don't know if I can finish it before the feature freeze at the end of the week...

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@carsonbot
Copy link

Could I get a reply or should I close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
0