{% use "bootstrap_5_horizontal_layout.html.twig" %} {% block collection_widget %} {% if prototype is defined and not prototype.rendered %} {% set attr = attr|merge({ 'data-prototype-code': form_row(prototype), 'data-prototype-placeholder': prototype.vars.name, 'data-prototype-index': prototype.parent.children|length > 0 ? prototype.parent.children|last.vars.name + 1 : 0, }) %} {% endif %} {{ block('form_widget') }} {% endblock collection_widget %} {% block collection_entry_row %} {% if expanded is defined and expanded %} {{ block('fieldset_form_row') }} {% else %} {% set widget_attr = {context_collection_entry: true} %} {% if help is not empty %} {% set widget_attr = {attr: {'aria-describedby': id ~"_help"}} %} {% endif %} {% set row_class = row_class|default(row_attr.class|default('mb-3')) %} {% set is_form_floating = is_form_floating|default('form-floating' in row_class) %} {% set is_input_group = is_input_group|default('input-group' in row_class) %} {#- Remove behavior class from the main container -#} {% set row_class = row_class|replace({'form-floating': '', 'input-group': ''}) %} {% if is_form_floating or is_input_group %}
{% if is_form_floating %}
{{ form_widget(form, widget_attr) }} {{ form_label(form) }}
{% elseif is_input_group %}
{{ form_label(form) }} {{ form_widget(form, widget_attr) }} {#- Hack to properly display help with input group -#} {{ form_help(form) }}
{% endif %} {% if not is_input_group %} {{ form_help(form) }} {% endif %} {{ form_errors(form) }}
{% else %} {{ form_label(form) }}
{{ form_widget(form, widget_attr) }} {{ form_help(form) }} {{ form_errors(form) }}
{% endif %} {% endif %} {% endblock %} {% block collection_entry_label %} {% if label is same as false %} {% else %} {{ block('form_label') }} {% endif %} {% endblock %} {% block collection_entry_widget %} {% set attr = {'class': 'row row-cols-lg-auto g-3 align-items-center collection-row'} %} {{ block('form_widget') }} {% endblock %} {% block collection_entry_add %}
{% endblock %} {% block collection_entry_delete %}
{% endblock %} {% block form_rows %} {% set child_vars = {} %} {% if not context_collection_entry|default(false) %} {% if allow_add is defined %} {% set child_vars = child_vars|merge({'allow_add': allow_add}) %} {% endif %} {% if allow_delete is defined %} {% set child_vars = child_vars|merge({'allow_delete': allow_delete}) %} {% endif %} {% endif %} {% if context_collection_entry is defined %} {% set child_vars = child_vars|merge({'context_collection_entry': context_collection_entry}) %} {% endif %} {% for child in form|filter(child => not child.rendered) %} {{ form_row(child, child_vars) }} {% endfor %} {% if context_collection_entry|default(false) %} {% if allow_delete|default(false) %} {{ block('collection_entry_delete') }} {% endif %} {% else %} {% if allow_add|default(false) %} {{ block('collection_entry_add') }}
{{ block('collection_entry_delete') }}
{% endif %} {% endif %} {% endblock form_rows %} {% block form_row %} {% set context_collection_entry = context_collection_entry|default(false) %} {% if expanded is defined and expanded %} {{ block('fieldset_form_row') }} {% else %} {% set widget_attr = {} %} {% if help is not empty %} {% set widget_attr = {attr: {'aria-describedby': id ~"_help"}} %} {% endif %} {% set row_class = row_class|default(row_attr.class|default(context_collection_entry ? '' : 'mb-3')) %} {% set is_form_floating = is_form_floating|default('form-floating' in row_class) %} {% set is_input_group = is_input_group|default('input-group' in row_class) %} {#- Remove behavior class from the main container -#} {% set row_class = row_class|replace({'form-floating': '', 'input-group': ''}) %}
{% if is_form_floating or is_input_group %}
{% if is_form_floating %}
{{ form_widget(form, widget_attr) }} {{ form_label(form) }}
{% elseif is_input_group %}
{{ form_label(form) }} {{ form_widget(form, widget_attr) }} {#- Hack to properly display help with input group -#} {{ form_help(form) }}
{% endif %} {% if not is_input_group %} {{ form_help(form) }} {% endif %} {{ form_errors(form) }}
{% else %} {{ form_label(form) }}
{{ form_widget(form, widget_attr) }} {{ form_help(form) }} {{ form_errors(form) }}
{% endif %}
{% endif %} {% endblock form_row %} {% block form_label -%} {% set context_collection_entry = context_collection_entry|default(false) %} {%- if label is same as(false) -%}
{%- else -%} {%- set row_class = row_class|default(row_attr.class|default('')) -%} {%- if 'form-floating' not in row_class and 'input-group' not in row_class -%} {%- 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('') ~ ' ' ~ (not context_collection_entry ? block('form_label_class')))|trim}) -%} {%- endif -%} {% if label is not same as(false) -%} {%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%} {%- if compound is defined and compound -%} {%- set element = 'legend' -%} {%- if 'col-form-label' not in parent_label_class -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label' )|trim}) -%} {%- endif -%} {%- else -%} {%- set row_class = row_class|default(row_attr.class|default('')) -%} {%- set label_attr = label_attr|merge({for: id}) -%} {%- if 'col-form-label' not in parent_label_class -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ('input-group' in row_class ? ' input-group-text' : ' form-label') )|trim}) -%} {%- endif -%} {%- endif -%} {%- endif -%} {% if label is not same as(false) -%} {% if not compound -%} {% set label_attr = label_attr|merge({'for': id}) %} {%- endif -%} {% if required -%} {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} {%- endif -%} <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}> {{- block('form_label_content') -}} {%- endif -%} {%- endif -%} {%- endblock form_label %}