Skip to content
Snippets Groups Projects
Commit 73d58362 authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Rely on the template loop for the ordering of the files

parent d0a4fe24
No related branches found
No related tags found
No related merge requests found
......@@ -36,10 +36,10 @@ class MultiFileInput(ClearableFileInput):
if not isinstance(upload, list):
upload = [upload]
checkbox_name = self.clear_checkbox_name(name)
checkbox_name = self.clear_checkbox_name(name) + '-'
checkboxes = {k for k in data if checkbox_name in k}
cleared = {
i for i, checkbox in enumerate(checkboxes)
int(checkbox.replace(checkbox_name, '')) for checkbox in checkboxes
if CheckboxInput().value_from_datadict(data, files, checkbox)
}
......
......@@ -4,9 +4,13 @@
</p>
{% for file in widget.value %}
<p>
<input type="checkbox" name="{{ widget.checkbox_name }}-{{ forloop.counter }}" id="{{ widget.checkbox_id }}-{{ forloop.counter }}">
<label for="{{ widget.checkbox_id }}-{{ forloop.counter }}"></label>
<a href="{{ file.url }}">{{ file }}</a>
{% with y=forloop.counter0|stringformat:"s" %}
{% with file_id=widget.checkbox_name|add:'-'|add:y %}
<input type="checkbox" name="{{ file_id }}" id="{{ file_id }}">
<label for="{{ file_id }}"></label>
{% endwith %}
{% endwith %}
<a href="{{ file.url }}">{{ file }}</a>
</p>
{% endfor %}
{{ widget.input_text }}{% endif %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment