Changing color of {{ form_help(‘ }} (Symfony 5.2)

I have a simple contact form. Within the form I would like to change the color of the help text

In FormType I added i. e. the name field:

            ->add('name', TextType::class, ['help' => 'Pflichtfeld'])

In Twig I have this:

<div class="row">
    <div class="col">
        {{ form_label(}}
        {{ form_widget( }}
        {{ form_help(, {'help_attr': {'class':'text-danger'}}) }}

Sadly the class is just added to the existing class when rendering and therefore is ignored:

<small id="contact_name_help" class="text-danger form-text text-muted">Pflichtfeld</small>

What do I need to do that the class defined in ‘help_attr’ ist overwriting the existing classes and is not just added?

Is it because I use ‘bootstrap_4_layout.html.twig’ as a form_theme in my twig.yaml?

Help is really appreciated!

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *