Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions frontend/editor/src/core/tools/formFill/FieldInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ function FieldInputInner({
);

case "checkbox": {
const isChecked = !!value && value !== "Off";
const onValue = (field.widgets && field.widgets[0]?.exportValue) || "Yes";
const exportVal = field.widgets && field.widgets[0]?.exportValue;
const isChecked = exportVal
? value === exportVal || value === "Yes"
: !!value && value !== "Off";
const onValue = exportVal || "Yes";
return (
<Checkbox
size="xs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,11 @@ function WidgetInputInner({
);

case "checkbox": {
// Checkbox is checked when value is anything other than 'Off' or empty
const isChecked = !!value && value !== "Off";
// When toggling on, use the widget's exportValue (e.g. 'Red', 'Blue') or fall back to 'Yes'
// Checkbox is checked when value matches exportValue if present, or is non-empty and not 'Off'
const isChecked = widget.exportValue
? value === widget.exportValue || value === "Yes"
: !!value && value !== "Off";
// When toggling on, use the widget's exportValue (e.g. 'Red', 'Blue', 'Pass') or fall back to 'Yes'
const onValue = widget.exportValue || "Yes";
return (
<div
Expand Down Expand Up @@ -433,6 +435,7 @@ function WidgetInputInner({
multiple={field.multiSelect}
style={{
...inputBaseStyle,
minWidth: "100%",
padding: 0,
paddingLeft: 2,
appearance: "auto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function toFormField(
// Derive value string
let value = f.value;
if (type === "checkbox") {
value = f.isChecked ? "Yes" : "Off";
value = f.isChecked ? f.widgets[0]?.exportValue || "Yes" : "Off";
} else if (type === "radio") {
// Use widget index as the canonical radio value.
// This avoids issues with duplicate exportValues across widgets
Expand Down
Loading