Edit on GitHub
Jump to docs navigation

Twig Components / Methods / form_label

form_label(orm_view, label, variables) is a Twig function to render the label for the given field. You can optionally pass the specific label you want to display as the second argument.

{{ form_label(form.name) }}

{# The two following syntaxes are equivalent #}
{{ form_label(form.name, 'Your Name', {'label_attr': {'class': 'foo'}}) }}

{{ form_label(form.name, null, {
    'label': 'Your name',
    'label_attr': {'class': 'foo'}
}) }}

Source: Forms

Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.