{% macro getFieldTemplate(type) -%}
    {%- set fieldTemplatePath = "freeform/_templates/formatting/basic-floating-labels/fields/" -%}
    {%- if type in ["text", "textarea", "email", "website", "confirm", "regex", "phone", "datetime", "number", "password"] -%}
        {{- fieldTemplatePath ~ "floating.twig" -}}
    {%- else -%}
        {{- fieldTemplatePath ~ type ~ ".twig" -}}
    {%- endif -%}
{%- 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: [
                                "freeform-col-" ~ width,
                                "freeform-fieldtype-" ~ field.type,
                            ],
                        }
                    }
                }) %}

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

            {% endfor %}
        {% endtag %}

    {% endfor %}

{% endmacro %}
