Last active
July 29, 2021 06:11
-
-
Save vaibhavpandeyvpz/e243770bcb8b7e516880bd198b23b2d6 to your computer and use it in GitHub Desktop.
Moving form errors in Symfony 4 form label to below input.
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
{% extends 'bootstrap_4_horizontal_layout.html.twig' %} | |
{% block form_label_errors %}{% endblock %} | |
{% block form_row -%} | |
{%- if expanded is defined and expanded -%} | |
{{ block('fieldset_form_row') }} | |
{%- else -%} | |
<div class="form-group row{% if (not compound or force_error|default(false)) and not valid %} is-invalid{% endif %}"> | |
{{- form_label(form) -}} | |
<div class="{{ block('form_group_class') }}"> | |
{{- form_widget(form) -}} | |
{{- form_errors(form) -}} | |
{{- form_help(form) -}} | |
</div> | |
</div> | |
{%- endif -%} | |
{%- endblock form_row %} |
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
{% extends 'bootstrap_4_layout.html.twig' %} | |
{% block form_label_errors %}{% endblock %} | |
{% 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') }} class="form-group"> | |
{{- form_label(form) -}} | |
{{- form_widget(form, widget_attr) -}} | |
{{- form_errors(form) -}} | |
{{- form_help(form) -}} | |
</{{ element|default('div') }}> | |
{%- endblock form_row %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment