diff --git a/python-tools/app/inputs.py b/python-tools/app/inputs.py index eebd41b..594593e 100644 --- a/python-tools/app/inputs.py +++ b/python-tools/app/inputs.py @@ -129,6 +129,12 @@ def validate_multi_choice( if field.required: return None, "Choose at least one option." return None, None + # The form's hidden empty value distinguishes deselection from omission. + raw_values = [value for value in raw_values if value != ""] + if not raw_values: + if field.required: + return None, "Choose at least one option." + return [], None allowed = {option.value for option in field.options} if any(value not in allowed for value in raw_values): return None, "Choose only from the available options." diff --git a/python-tools/templates/index.html b/python-tools/templates/index.html index dced5d4..8c625b9 100644 --- a/python-tools/templates/index.html +++ b/python-tools/templates/index.html @@ -51,6 +51,7 @@ {% elif field.type == "multi_choice" %}
{{ field.label }}{% if field.required %} (required){% endif %} + {% set selected = values.get(field.name, field.default or ()) %} {% for option in field.options %}