Marking Symfony forms required fields with an asterisk

Published on 2020-08-25 • Modified on 2020-08-25

In this snippet, we will see how to mark with an asterisk all the required fields of a Symfony form. We will do it with CSS. Inspect the login and password label elements; you will see that the "*" is not hardcoded but comes from the CSS rule we added. Check out the links below to view different approaches to achieve the same goal.

label.required:before {
    content: "*";
    color: red;
HTML demo of the snippet

 More on Stackoverflow   Read the doc  More on the web  Random snippet

  Work with me!