Skip to content

Commit

Permalink
Properly process and validate field values from sample header on subm…
Browse files Browse the repository at this point in the history
…it (#2311)

* Properly process and validate field values from sample header on submit

* Changelog
  • Loading branch information
xispa committed May 16, 2023
1 parent d38641e commit 3fd052d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
2.5.0 (unreleased)
------------------

- #2311 Properly process and validate field values from sample header on submit
- #2307 Rely on fields when validating submitted values on sample creation
- #2305 Add support for dates in ANSI X3.30 and ANSI X3.43.3 formats
- #2304 Fix dynamic sample specification not applied for new samples
Expand Down
9 changes: 8 additions & 1 deletion src/senaite/core/browser/viewlets/sampleheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,18 @@ 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 <fieldname>_uid. Otherwise, we could simply
# pass the form object to the widget's process_form function.
value = self.get_field_value(field, form)

if value is _fieldname_not_in_form:
continue

# process the value as the widget would usually do
process_value = field.widget.process_form
value, msgs = process_value(self.context, field, {name: value})

# Keep track of field-values
field_values.update({name: value})

Expand Down

0 comments on commit 3fd052d

Please sign in to comment.