Skip to content

Commit aee08da

Browse files
committed
Fix edge case where error is thrown on empty choice field
1 parent d446161 commit aee08da

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/reactpy_django/forms/utils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ def convert_multiple_choice_fields(data: dict[str, Any], initialized_form: Form
1414

1515
# Convert multiple choice field text into a list of values
1616
for choice_field_name in multi_choice_fields:
17-
if not isinstance(data.get(choice_field_name), list):
18-
data[choice_field_name] = [data[choice_field_name]]
17+
value = data.get(choice_field_name)
18+
if value is not None and not isinstance(value, list):
19+
data[choice_field_name] = [value]
1920

2021

2122
def convert_boolean_fields(data: dict[str, Any], initialized_form: Form | ModelForm) -> None:

0 commit comments

Comments
 (0)