{% extends '@Contao/form_row.html.twig' %}

{% block label %}
    {% if this.label %}
        <label for="ctrl_{{ this.id }}"{% if this.class|default %} class="{{ this.class|default }}"{% endif %}>
            {% if this.mandatory|default %}
                <span class="invisible">{{ this.mandatoryField }} </span>{{ this.label|insert_tag_raw }}<span class="mandatory">*</span>
            {% else %}
                {{ this.label|insert_tag_raw }}
            {% endif %}
        </label>
    {% endif %}
{% endblock %}

{% block field %}
    {% if hasErrors.invoke() %}
        <p class="error">{{ getErrorAsString.invoke() }}</p>
    {% endif %}

    <input{{ attrs()
        .set('type', 'file')
        .set('name', this.name)
        .set('id', "ctrl_#{this.id}")
        .addClass('upload')
        .addClass(this.class|default)
        .set('aria-describedby', "help_ctrl_#{this.id}", this.help|default)
        .set('multiple', true, this.multipleFiles|default)
        .mergeWith(getAttributes.invoke())
    }}>

    {% if this.help|default %}
        <p class="help" id="help_ctrl_{{ this.id }}">{{ this.help|insert_tag_raw }}</p>
    {% endif %}
{% endblock %}
