{% macro getFieldTemplate(type) -%}
    {% set fieldTemplatePath = "freeform/_templates/formatting/bootstrap-5-dark/fields/" -%}
    {{- fieldTemplatePath ~ type ~ ".twig" -}}
{%- endmacro %}

{% macro render(rows, form) %}
    {% import _self as self %}

    {% for row in rows %}

        {% set width = (12 / (row|length)) %}

        {% set attributes = form.attributes.row %}
        {% tag attributes.tag with attributes.toHtmlTagArray %}

            {% for field in row %}

                {% do field.setParameters({
                    attributes: {
                        container: {
                            class: [
                                "col-sm-" ~ width,
                                "freeform-fieldtype-" ~ field.type,
                            ],
                        },
                    }
                }) %}

                {% include [self.getFieldTemplate(field.type), self.getFieldTemplate("_default")] %}

            {% endfor %}
        {% endtag %}

    {% endfor %}

{% endmacro %}
