{% set labelname = input.label %}
{% set caption = input.caption %}
{% set tabindex = groupindex or 0 %}

{% if input.type == 'section' %}
	<h4 class="section-header">{{input.label}}</h4>
{% endif %}

{# ------------- WRAPPER DIV FIELDS --------------- #}
{% if input.type not in ('hidden','divider','section','html') %}
<div class="form-row" tabindex="0"> {# starting row wrapping div #}
{% endif %}

{# ------------ TEXT INPUT ------------ #}
{% if input.type in ('text','password','number','tel','url','color','email','date','hidden' ) %}
	{% include('/form_partials/text.html') %}

{# ------------- CHECKBOX FIELDS --------------- #}
{% elif input.type in ('checkbox','radio') %}
    {% set grouped = False %}
	{% if input.inputs %}
        {% set grouped = True %}
		<label class="form-label{% if input.required %} required{% endif %}">{{input.label}}</label>
		{% for choice in input.inputs %}
			{% include('/form_partials/checkbox.html') %}
		{% endfor %}
	{% else %}
		{% include('/form_partials/checkbox.html') %}
	{% endif %}
{% if input.required %}
<small class="input_error_msg {{input.label_for}}">{{input.label|title or 'This field'}} is required</small>
{% endif %}
{# ------------- SELECT FIELDS --------------- #}
{% elif input.type == 'select' %}
	{% include('/form_partials/select.html') %}

{# ------------- HTML FIELDS --------------- #}
{% elif input.type == 'html' %}
	{% include('/form_partials/html.html') %}


{# ------------- TEXTAREA FIELDS --------------- #}
{% elif input.type == 'textarea' %}
	{% include('/form_partials/textarea.html') %}

{# ------------- FILE FIELDS --------------- #}
{% elif input.type == 'file' %}
	{% include('/form_partials/file-input.html') %}

{# ------------- SUBMIT BUTTON --------------- #}
{% elif input.type in ('submit','button') %}
	{% include('/form_partials/button.html') %}
{% else %}
	{% include('/form_partials/text.html') %}
{% endif %}

{% if (input.content and input.type != 'html') or caption %}
<small class="form-input-caption">{{input.content or caption}}</small>
{% endif %}
{% if input.type not in ('divider','hidden','section','html') %}
</div> {# ending row wrapping div #}
{% endif %}
