A
A
AlpineMilk2019-01-19 20:31:16
symfony
AlpineMilk, 2019-01-19 20:31:16

How to change label in Symfony forms for whole template?

I want to change all the label for the page, for this I need to override the form_label of the bootstrap theme I'm using
Here is my code:

{% block content %}
    {% form_theme form 'bootstrap_3_layout.html.twig' %}
    .....
{% endblock %}

{% block form_label %}
    {% set label_attr = label_attr|merge({class: ('mb-10')|trim}) %}
    {{ parent() }}
{% endblock form_label %}

I removed the default classes and added my own, but nothing has changed. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2019-01-20
@AlpineMilk

Did you specify in the yaml config symphony that you need to use your template with your blocks?

D
Dmitry, 2019-01-30
@jetdigger

https://symfony.com/doc/current/form/form_themes.html
Reusing Parts of a Built-In Form Theme
Finally, you can also use the Twig parent() function to reuse the original content of the built-in theme. This is useful when you only want to make minor changes, such as wrapping the generated HTML with some element:

{% use 'form_div_layout.html.twig' %}

{% block integer_widget %}
    <div class="some-custom-class">
        {{ parent() }}
    </div>
{% endblock %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question