Skip to content

Commit

Permalink
🐛 [#4980] Add empty string to list of choices to account for an unfil…
Browse files Browse the repository at this point in the history
…led field

Non-required fields can be empty upon submission, so need to include an empty string.
  • Loading branch information
viktorvanwijk committed Jan 22, 2025
1 parent 41c3c81 commit 2166e2f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/openforms/formio/components/vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ def as_json_schema(component: SelectComponent) -> JSONObject:
label = component.get("label", "Select")

choices = [options["value"] for options in component["data"]["values"]]
choices.append("") # Take into account an unfilled field

base = {"type": "string", "enum": choices}
if multiple:
Expand Down Expand Up @@ -845,6 +846,8 @@ def as_json_schema(component: RadioComponent) -> JSONObject:
label = component.get("label", "Radio")

choices = [options["value"] for options in component["values"]]
choices.append("") # Take into account an unfilled field

base = {"title": label, "type": "string", "enum": choices}

return base
Expand Down

0 comments on commit 2166e2f

Please sign in to comment.