diff --git a/opentech/apply/stream_forms/fields.py b/opentech/apply/stream_forms/fields.py index d0b240eb3990173e90f1ff595c4da64d060f03d4..a6c46c9690dd99efdeb4abdd971bd94f655be8a1 100644 --- a/opentech/apply/stream_forms/fields.py +++ b/opentech/apply/stream_forms/fields.py @@ -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) } diff --git a/opentech/apply/stream_forms/templates/stream_forms/fields/multi_file_field.html b/opentech/apply/stream_forms/templates/stream_forms/fields/multi_file_field.html index de66cb4cc793fa35f975ed0b89aef02b09b99947..e48370c3e80349b72ab6c42389e0379262f721c8 100644 --- a/opentech/apply/stream_forms/templates/stream_forms/fields/multi_file_field.html +++ b/opentech/apply/stream_forms/templates/stream_forms/fields/multi_file_field.html @@ -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 %}