From c52dd4ec423f06e851830687c8e446cc14387451 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Thu, 14 Mar 2024 01:25:02 +0100 Subject: [PATCH] Add support for the "accept" attribute on file inputs. If the widget's field - if there is one - has the "accept" attribute set (the `NamedImage` field has `image/*` set by default) then this is rendered as an `accept` attribute on the file input. This would restrict the allowed file types before uploading while still being checked on the server side. Fixes: https://github.com/plone/plone.formwidget.namedfile/issues/66 Depends on: - https://github.com/plone/plone.namedfile/pull/158 - https://github.com/plone/plone.formwidget.namedfile/pull/67 --- news/198.feature | 14 ++++++++++++++ plone/app/z3cform/templates/file_input.pt | 1 + plone/app/z3cform/templates/image_input.pt | 1 + setup.py | 1 + 4 files changed, 17 insertions(+) create mode 100644 news/198.feature diff --git a/news/198.feature b/news/198.feature new file mode 100644 index 00000000..1d722dc4 --- /dev/null +++ b/news/198.feature @@ -0,0 +1,14 @@ +Add support for the "accept" attribute on file inputs. + +If the widget's field - if there is one - has the "accept" attribute set (the +`NamedImage` field has `image/*` set by default) then this is rendered as an +`accept` attribute on the file input. + +This would restrict the allowed file types before uploading while still being +checked on the server side. + +Fixes: https://github.com/plone/plone.formwidget.namedfile/issues/66 +Depends on: +- https://github.com/plone/plone.namedfile/pull/158 +- https://github.com/plone/plone.formwidget.namedfile/pull/67 +[thet] diff --git a/plone/app/z3cform/templates/file_input.pt b/plone/app/z3cform/templates/file_input.pt index 14bd91a5..5df43142 100644 --- a/plone/app/z3cform/templates/file_input.pt +++ b/plone/app/z3cform/templates/file_input.pt @@ -90,6 +90,7 @@ =1.3.6", "plone.base", "plone.app.contentlisting", + "plone.formwidget.namedfile>3.0.3", "plone.i18n", "plone.protect", "plone.registry",