You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f02ef49
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/en/docs/release-notes.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,12 @@ hide:
7
7
8
8
## Latest Changes
9
9
10
+
Omitted `bool` and `bool | None` form fields now use their declared defaults or produce missing-field errors, consistent with other fields and Pydantic behavior. FastAPI no longer infers `False` for omitted booleans. This applies to individual form parameters, form models, and unions of form models.
11
+
12
+
Omitted boolean model fields are excluded from `model_dump(exclude_unset=True)`, and their defaults no longer count as submitted fields during union selection. Default factories and `validate_default` follow the usual rules.
13
+
14
+
For HTML checkboxes, declare a boolean with a default of `False`. See [Boolean Form Fields](https://fastapi.tiangolo.com/tutorial/request-forms/#boolean-form-fields).
Copy file name to clipboardExpand all lines: docs/en/docs/tutorial/request-forms.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,9 +46,11 @@ To declare form bodies, you need to use `Form` explicitly, because without it th
46
46
47
47
## Boolean Form Fields { #boolean-form-fields }
48
48
49
-
Browsers omit unchecked checkboxes. **FastAPI** treats omitted `bool` and `bool | None`form fields as `False`, even when their default is `True` or `None`.
49
+
Browsers omit unchecked checkboxes when submitting HTML forms. Declare a boolean form parameter with a default of `False` to receive `False` when unchecked:
50
50
51
-
For JSON requests and direct Pydantic validation, required fields and defaults work as usual.
0 commit comments