Answer the question
In order to leave comments, you need to log in
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 %}
Answer the question
In order to leave comments, you need to log in
Did you specify in the yaml config symphony that you need to use your template with your blocks?
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 questionAsk a Question
731 491 924 answers to any question