diff --git a/news/35.bugfix b/news/35.bugfix new file mode 100644 index 0000000..32a1fc9 --- /dev/null +++ b/news/35.bugfix @@ -0,0 +1 @@ +Fix `NamedFileWidget` bug when trying to create value from `None`. [vangheem] \ No newline at end of file diff --git a/plone/formwidget/namedfile/widget.py b/plone/formwidget/namedfile/widget.py index c97920d..0f974fd 100644 --- a/plone/formwidget/namedfile/widget.py +++ b/plone/formwidget/namedfile/widget.py @@ -307,7 +307,8 @@ def extract(self, default=NOVALUE): dm = getMultiAdapter((self.context, self.field,), IDataManager) # For sub-widgets to function use a query() not get() data = dm.query(default) - data = _make_namedfile(data, self.field, self.context) + if data is not None: + data = _make_namedfile(data, self.field, self.context) return data # empty unnamed FileUploads should not count as a value