Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony2 render form collection as ul
    primarykey
    data
    text
    <p>I got a big collection of forms which I would like to render this way:</p> <pre><code>&lt;form&gt; &lt;fieldset&gt; &lt;legend&gt;Form One&lt;/legend&gt; &lt;ul&gt; &lt;li&gt;&lt;label&gt;Label 1&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;li&gt;&lt;label&gt;Label 2&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;li&gt;&lt;label&gt;Label 3&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;li&gt;&lt;label&gt;Label 4&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;li&gt;&lt;label&gt;Label 5&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;li&gt;&lt;label&gt;Label 6&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/fieldset&gt; &lt;fieldset&gt; &lt;legend&gt;Form Two&lt;/legend&gt; &lt;ul&gt; &lt;li&gt;&lt;label&gt;Label 1&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;li&gt;&lt;label&gt;Label 2&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;li&gt;&lt;label&gt;Label 3&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;li&gt;&lt;label&gt;Label 4&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;li&gt;&lt;label&gt;Label 5&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;li&gt;&lt;label&gt;Label 6&lt;/label&gt;&lt;input /&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p>and so on.</p> <p>I now tried hours to get this using form themes, I even played around with vendor/symfony/src/bridge/Twig/Ressources/view/Form/form_div_layout.html.twig</p> <p>But I don't success, twig always renders the subforms with li's instead of fieldset's and so on</p> <p>Has someone any idea what I could do?</p> <pre><code>{% use "form_div_layout.html.twig" %} {% block field_row %} &lt;li&gt; {{ form_label(form, label|default(null)) }} {{ form_widget(form) }} &lt;/li&gt; {% endblock field_row %} {% block form_errors %} {% if errors|length &gt; 0 %} {{ block('field_errors') }} {% endif %} {% endblock form_errors %} {% block field_errors %} {% if errors|length &gt; 0 %} &lt;ul&gt; {% for error in errors %} &lt;li&gt;{{ error.messageTemplate|trans(error.messageParameters, 'validators') }}&lt;/li&gt; {% endfor %} &lt;/ul&gt; {% endif %} {% endblock field_errors %} {% block hidden_row %} &lt;b&gt;{{ form_widget(form) }}&lt;/b&gt; {% endblock hidden_row %} {% block form_widget %} &lt;ul {{ block('widget_container_attributes') }}&gt; {{ block('field_rows') }} {{ form_rest(form) }} &lt;/ul&gt; {% endblock form_widget %} {% block collection_widget %} {% if prototype is defined %} {% set attr = attr|merge({'data-prototype': form_row(prototype) }) %} {% endif %} {{ block('form_widget') }} {% endblock collection_widget %} </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload