2018-03-29 11:56:53 +01:00
|
|
|
{% macro file_upload(
|
|
|
|
|
field,
|
|
|
|
|
action=None,
|
|
|
|
|
button_text="Choose file",
|
|
|
|
|
alternate_link=None,
|
2018-09-26 16:42:40 +01:00
|
|
|
alternate_link_text=None,
|
|
|
|
|
hint=None
|
|
|
|
|
|
2018-03-29 11:56:53 +01:00
|
|
|
) %}
|
|
|
|
|
<form method="post" enctype="multipart/form-data" {% if action %}action="{{ action }}"{% endif %} class="{% if field.errors %}form-group-error{% endif %}" data-module="file-upload">
|
2016-02-02 17:28:30 +00:00
|
|
|
<label class="file-upload-label" for="{{ field.name }}">
|
2017-02-13 09:50:26 +00:00
|
|
|
<span class="visually-hidden">{{ field.label.text }}</span>
|
2016-02-02 17:28:30 +00:00
|
|
|
{% if hint %}
|
|
|
|
|
<span class="form-hint">
|
|
|
|
|
{{ hint }}
|
|
|
|
|
</span>
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% if field.errors %}
|
|
|
|
|
<span class="error-message">
|
|
|
|
|
{{ field.errors[0] }}
|
|
|
|
|
</span>
|
|
|
|
|
{% endif %}
|
|
|
|
|
</label>
|
|
|
|
|
{{ field(**{
|
|
|
|
|
'class': 'file-upload-field'
|
|
|
|
|
}) }}
|
|
|
|
|
<label class="file-upload-button" for="{{ field.name }}">
|
2016-02-04 12:20:24 +00:00
|
|
|
{{ button_text }}
|
2016-02-02 17:28:30 +00:00
|
|
|
</label>
|
2016-05-05 08:39:36 +01:00
|
|
|
{% if alternate_link and alternate_link_text %}
|
|
|
|
|
<span class="file-upload-alternate-link">
|
|
|
|
|
or <a href="{{ alternate_link }}">{{ alternate_link_text }}</a>
|
|
|
|
|
</span>
|
|
|
|
|
{% endif %}
|
2016-02-02 17:28:30 +00:00
|
|
|
<label class="file-upload-filename" for="{{ field.name }}"></label>
|
2016-02-22 21:37:32 +00:00
|
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
2018-02-01 13:32:27 +00:00
|
|
|
<button type="submit" class="file-upload-submit">Submit</button>
|
2016-02-22 21:37:32 +00:00
|
|
|
</form>
|
2016-02-02 17:28:30 +00:00
|
|
|
{% endmacro %}
|