Last active
July 18, 2020 07:43
-
-
Save felixprojekt/ea74cb323a0b0f0b4385008d75485a12 to your computer and use it in GitHub Desktop.
Add form field ID to form-group element in Symfony 4 bootstrap theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% use "bootstrap_4_layout.html.twig" %} | |
{% block form_row -%} | |
{%- if compound is defined and compound -%} | |
{%- set element = 'fieldset' -%} | |
{%- endif -%} | |
{%- set widget_attr = {} -%} | |
{%- if help is not empty -%} | |
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%} | |
{%- endif -%} | |
<{{ element|default('div') }}{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group ' ~ id ~ '-group')|trim})} %}{{ block('attributes') }}{% endwith %}> | |
{{- form_label(form) -}}{{- form_help(form) -}} | |
{{- form_widget(form, widget_attr) -}} | |
</{{ element|default('div') }}> | |
{%- endblock form_row %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add to
twig.yaml