Closed
Description
Since form errors are rendered inside the <label>
, it's not possible to add the common red asterisk (to indicate a required field) in the "usual" way:
label.required:after { content:"*"; color:red; }
... cause when a form error is present, the result looks like this:
Your name
ERROR
*
... instead of:
Your name *
ERROR
So what's the best way of doing it??
In Symfony 5.1, you can use label_html
in the FormType, see https://symfony.com/doc/current/reference/forms/types/form.html#label-html
->add('name', TextType::class, ['label' => 'Your name <strong>*</strong>', 'label_html' => true])
So if there's no better/other way, I'd suggest to explain this at https://symfony.com/doc/current/form/bootstrap4.html