Hello everyone,
again I am solving a problem that seemed solved and I can’t find a solution.
Please, how do I limit the generation of multiple variables below each other so that the result is not duplicated?
My form loads 1-5 folders, if I choose one, its name and link will be generated correctly, but if I choose two or more, the lists of folders below me will be displayed:
Example:
For one file:
(Correct)
* Show file: File.jpg
For 3 files:
(Problem)
* Show file: File.jpg
* Show file: File1.jpg
* Show file: File2.jpg
* Show file: File.jpg
* Show file: File1.jpg
* Show file: File2.jpg
* Show file: File.jpg
* Show file: File1.jpg
* Show file: File2.jpg
Code:
<ul>
{% for val in value %}
{% if val is iterable %}
<ul>
{% for item in form.value(field.name) %}
<li>Show file: <a href="..//{{ string(item.path) }}" download target="_blank">{{ item.name }}</a></li>
{% endfor %}
</ul>
{% else %}
<li>{{ string(form.value(field.name))|nl2br }}</li>
{% endif %}
{% endfor %}
</ul>
this is the part of code from: “data.html.twig”
I try some like this: merge - Documentation - Twig - The flexible, fast, and secure PHP template engine
But not the solution.
How can I fix this, thank you all very much for their time.