diff --git a/wagtailstreamforms/wagtailstreamforms_fields.py b/wagtailstreamforms/wagtailstreamforms_fields.py index d76c7ad4..1ccc1dcb 100644 --- a/wagtailstreamforms/wagtailstreamforms_fields.py +++ b/wagtailstreamforms/wagtailstreamforms_fields.py @@ -4,6 +4,8 @@ from django.utils.translation import gettext_lazy as _ from wagtail import blocks +from django.forms.widgets import ClearableFileInput + from wagtailstreamforms.conf import get_setting from wagtailstreamforms.fields import BaseField, register @@ -212,7 +214,18 @@ def get_form_block(self): ) +class MultiFileInput(ClearableFileInput): + input_type = 'file' + template_name = 'django/forms/widgets/multifileinput.html' + + def __init__(self, attrs=None, *args, **kwargs): + attrs = attrs or {} + attrs.update({'multiple': True}) + super().__init__(attrs, *args, **kwargs) + + class MultiFileField(BaseField): + widget = MultiFileInput() field_class = forms.FileField widget = forms.widgets.FileInput(attrs={"multiple": True}) icon = "doc-full-inverse"