| {% macro render_field(field, type) %}

.form-group(class="{{field.name}}{% if field.errors %} error{% endif %}")

	| {% if field.type == 'BooleanField' %}
	.checkbox
		label
			| {{ field(class='checkbox') }}
			label {{ field.name | undertitle }}

	| {% elif field.type == 'FieldList' %}

	ul.fieldlist(id="{{ type }}")
		| {% for file in field %}
		li.fieldlist-item

			| {% for subfield in file %}
			| {{ render_field(subfield) }}

			| {% if subfield.name.endswith('slug') %}
			button.fieldlist-action-button.js-append-attachment(
				type="button", data-clipboard)
				i.pi-plus
				| Copy to clipboard
			| {% endif %}

			| {% endfor %}

		| {% endfor %}

	| {% else %}
	| {{ field.label }}
	| {{ field(class='form-control') }}
	| {% endif %}

	| {% if field.errors %}
	ul.error
		| {% for error in field.errors %}
		li {{ error }}
		| {% endfor %}
	| {% endif %}

| {% endmacro %}
