diff --git a/CHANGES.rst b/CHANGES.rst index 222f446c91..5eab437cd5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,7 @@ Changelog 2.5.0 (unreleased) ------------------ +- #2364 Support for fieldname-prefixed values on sample header submit - #2363 Auto-hide non-multivalued reference widget input on value selection - #2359 Improve sample create performance - #2361 Fix KeyError if registry key not found diff --git a/src/senaite/core/browser/viewlets/sampleheader.py b/src/senaite/core/browser/viewlets/sampleheader.py index e556d1c74d..46318eb7af 100644 --- a/src/senaite/core/browser/viewlets/sampleheader.py +++ b/src/senaite/core/browser/viewlets/sampleheader.py @@ -74,17 +74,20 @@ def handle_form_submit(self, request=None): form = request.form for name, field in self.fields.items(): - # get the raw value from the form. This shouldn't be necessary, - # but there are still some widgets out there with a name that - # follows the format _uid. Otherwise, we could simply - # pass the form object to the widget's process_form function. + # get the raw value from the form value = self.get_field_value(field, form) if value is _fieldname_not_in_form: continue + # some legacy widgets need values with _ as prefix + prefix = "{}_".format(name) + extra = filter(lambda key: key.startswith(prefix), form.keys()) + form_values = dict((key, form[key]) for key in extra) + form_values[name] = value + # process the value as the widget would usually do process_value = field.widget.process_form - value, msgs = process_value(self.context, field, {name: value}) + value, msgs = process_value(self.context, field, form_values) # Keep track of field-values field_values.update({name: value})