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

{# Labels #}

{% block form_label -%}
    {%- if label is same as(false) -%}
        <div class="{{ block('form_label_class') }}"></div>
    {%- else -%}
        {%- if expanded is not defined or not expanded -%}
            {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%}
        {%- endif -%}
        {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) -%}
        {{- parent() -}}
    {%- endif -%}
{%- endblock form_label %}

{% block form_label_class -%}
col-sm-2
{%- endblock form_label_class %}

{# Rows #}

{% 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) -}}
            </div>
    {##}</div>
    {%- endif -%}
{%- endblock form_row %}

{% block fieldset_form_row -%}
    <fieldset class="form-group">
        <div class="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) -}}
            </div>
        </div>
{##}</fieldset>
{%- endblock fieldset_form_row %}

{% block submit_row -%}
    <div class="form-group row">{#--#}
        <div class="{{ block('form_label_class') }}"></div>{#--#}
        <div class="{{ block('form_group_class') }}">
            {{- form_widget(form) -}}
        </div>{#--#}
    </div>
{%- endblock submit_row %}

{% block reset_row -%}
    <div class="form-group row">{#--#}
        <div class="{{ block('form_label_class') }}"></div>{#--#}
        <div class="{{ block('form_group_class') }}">
            {{- form_widget(form) -}}
        </div>{#--#}
    </div>
{%- endblock reset_row %}

{% block form_group_class -%}
col-sm-10
{%- endblock form_group_class %}

{% block checkbox_row -%}
    <div class="form-group row">{#--#}
        <div class="{{ block('form_label_class') }}"></div>{#--#}
        <div class="{{ block('form_group_class') }}">
            {{- form_widget(form) -}}
            {{- form_errors(form) -}}
        </div>{#--#}
    </div>
{%- endblock checkbox_row %}
