From 52b2b3a62f6076ece9b64dd43d316a9d2c4b9482 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 6 Jun 2026 09:51:36 +1000 Subject: [PATCH] Fix for empty boolean fields (#12100) (#12101) (cherry picked from commit b9c063fe31d37cf081cbfc473857226524158c7b) Co-authored-by: Oliver --- src/frontend/lib/functions/Navigation.tsx | 2 +- src/frontend/src/components/forms/fields/BooleanField.tsx | 4 ++-- src/frontend/src/forms/CommonForms.tsx | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/frontend/lib/functions/Navigation.tsx b/src/frontend/lib/functions/Navigation.tsx index 21e9324d20..939dd02115 100644 --- a/src/frontend/lib/functions/Navigation.tsx +++ b/src/frontend/lib/functions/Navigation.tsx @@ -55,7 +55,7 @@ export function getDetailUrl( } } - console.error(`No detail URL found for model ${model} <${pk}>`); + console.warn(`No detail URL found for model ${model} <${pk}>`); return ''; } diff --git a/src/frontend/src/components/forms/fields/BooleanField.tsx b/src/frontend/src/components/forms/fields/BooleanField.tsx index c05b04f393..475c7628e5 100644 --- a/src/frontend/src/components/forms/fields/BooleanField.tsx +++ b/src/frontend/src/components/forms/fields/BooleanField.tsx @@ -25,9 +25,9 @@ export function BooleanField({ const { value } = field; - // Set default value if value is undefined + // Set default value if value is undefined or otherwise empty useEffect(() => { - if (value === undefined) { + if (value === undefined || value === null || value === '') { onChange(definition.default ?? false); } }, [value, definition]); diff --git a/src/frontend/src/forms/CommonForms.tsx b/src/frontend/src/forms/CommonForms.tsx index 6c96e48d2f..46b3663420 100644 --- a/src/frontend/src/forms/CommonForms.tsx +++ b/src/frontend/src/forms/CommonForms.tsx @@ -173,6 +173,7 @@ export function useParameterFields({ // This is a "checkbox" field setChoices([]); setFieldType('boolean'); + setData('false'); } else if (record?.choices) { const _choices: string[] = record.choices.split(',');