0

I have this:

<fieldset>
    <legend>{{ form_label(form.fees, 'fees' | trans , { 'label_attr': {'class': 'col-sm-3 control-label'} }) }}</legend>
    <div class="large-12 columns fees">
        <br/>
        {{ form_errors(form.fees) }}
        <div class="col-sm-5">
            {{ form_widget(form.fees, { 'attr': {'class': 'form-control validate[required]'} }) }}
        </div>
    </div>
</fieldset>

This line:
{{ form_widget(form.fees, { 'attr': {'class': 'form-control validate[required]'} }) }}

print:

<label></label>
<input />
<label></label>
<input />

But i need something like this(with wrappers):

<div><label></label><input /></div>
<div><label></label><input /></div>

Tnx!! :)

1
  • 4
    Sounds like form themes is what you're looking for. The link chapter I linked points to a method suitable if you want to customize only a specific form (not all of them). To modify all of the forms, scroll down a bit. Commented Sep 24, 2015 at 19:19

2 Answers 2

3
+50

In case you would like to have rows of four checkboxes, that will be something like:

{# Wrap span around checkboxes #}
{{ form_label(form.fees) }}
{{ form_errors(form.fees) }}<br>
{% for batch in form.fees|batch(4) %}
    <div class="batchRow">
        {% for option in batch %}
            <div class="yourClassName">
                {{ form_label(option) }}
                {{ form_widget(option) }}
            </div>
        {% endfor %}
    </div>
{% endfor %}

Otherwise you can get rid of the batch level.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use customize an individual field. for example you have ProductType form and your case is fee. So, you can add this line in your top code:

{# tell symfony use form theme #}
{% form_theme form _self %}

{# the block customize #}
{% block _product_fees_widget %}
    <div>
        {{ block('form_widget_simple') }}
    </div>
{% endblock %}

{# print #}
{{ form_widget(form.fees, { 'attr': {'class': 'form-control validate[required]'} }) }}

for more information, please read this FORM THEME

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.