{% use "form_div_layout.html.twig" %}

{% block button_row -%}
	<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>
		{{- form_widget(form) -}}
	</div>
{%- endblock button_row %}

{% block button_widget -%}
	{%- set attr = attr|merge({class: (attr.class|default('btn-secondary') ~ ' btn')|trim}) -%}
	{{- parent() -}}
{%- endblock button_widget %}

{% block submit_widget -%}
	{%- set attr = attr|merge({class: (attr.class|default('btn-primary'))|trim}) -%}
	{{- parent() -}}
{%- endblock submit_widget %}

{% block form_label -%}
	{% if label is not same as(false) -%}
		{%- if compound is defined and compound -%}
			{%- set element = 'legend' -%}
			{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-label')|trim}) -%}
		{%- else -%}
			{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-label')|trim}) -%}
			{%- set label_attr = label_attr|merge({for: id}) -%}
		{%- endif -%}
		{% if label is empty -%}
			{%- if label_format is not empty -%}
				{% set label = label_format|replace({
					'%name%': name,
					'%id%': id,
				}) %}
			{%- else -%}
				{% set label = name|humanize %}
			{%- endif -%}
		{%- endif -%}
		<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain) }}{% block form_label_errors %}{{- form_errors(form) -}}{% endblock form_label_errors %}</{{ element|default('label') }}>
	{%- else -%}
		{%- if errors|length > 0 -%}
			<div id="{{ id }}_errors" class="mb-2">
				{{- form_errors(form) -}}
			</div>
		{%- endif -%}
	{%- endif -%}
{%- endblock form_label %}

{% block form_widget_simple -%}
	{% if type is not defined or type != 'hidden' %}
		{%- set attr = attr|merge({class: (attr.class|default('') ~ (type|default('') == 'file' ? ' custom-file-input' : ' form-input'))|trim}) -%}
	{% endif %}
	{%- if type is defined and (type == 'range' or type == 'color') %}
		{# Attribute "required" is not supported #}
		{%- set required = false -%}
	{% endif %}
	{{- parent() -}}
{%- endblock form_widget_simple %}

{% 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')|trim})} %}{{ block('attributes') }}{% endwith %}>
	{{- form_label(form) -}}
	{{- form_widget(form, widget_attr) -}}
	{{- form_help(form) -}}
	</{{ element|default('div') }}>
{%- endblock form_row %}

