Skip to content

Commit

Permalink
Safe fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Sep 3, 2024
1 parent 5727080 commit 90b1563
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion form_designer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,12 @@ def loader(submission, field, choice_dict):
value = submission.data[field.name]
elif (old := field._old_name) is not None and old in submission.data:
value = submission.data[old]
return choice_dict.get(value, value)
try:
if isinstance(value, list):
return [choice_dict.get(v, v) for v in value]
return choice_dict.get(value, value)
except TypeError: # unhashable types or other, unexpected circumstances
return value

def old_name_loader(submission, old_name):
return submission.data.get(old_name)
Expand Down

0 comments on commit 90b1563

Please sign in to comment.