Skip to content

Commit 74be5bf

Browse files
fix(forms): Fix checkbox export values and wide dropdown options (#7288)
Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
1 parent 8c00fff commit 74be5bf

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

frontend/editor/src/core/tools/formFill/FieldInput.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ function FieldInputInner({
6868
);
6969

7070
case "checkbox": {
71-
const isChecked = !!value && value !== "Off";
72-
const onValue = (field.widgets && field.widgets[0]?.exportValue) || "Yes";
71+
const exportVal = field.widgets && field.widgets[0]?.exportValue;
72+
const isChecked = exportVal
73+
? value === exportVal || value === "Yes"
74+
: !!value && value !== "Off";
75+
const onValue = exportVal || "Yes";
7376
return (
7477
<Checkbox
7578
size="xs"

frontend/editor/src/core/tools/formFill/FormFieldOverlay.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,11 @@ function WidgetInputInner({
338338
);
339339

340340
case "checkbox": {
341-
// Checkbox is checked when value is anything other than 'Off' or empty
342-
const isChecked = !!value && value !== "Off";
343-
// When toggling on, use the widget's exportValue (e.g. 'Red', 'Blue') or fall back to 'Yes'
341+
// Checkbox is checked when value matches exportValue if present, or is non-empty and not 'Off'
342+
const isChecked = widget.exportValue
343+
? value === widget.exportValue || value === "Yes"
344+
: !!value && value !== "Off";
345+
// When toggling on, use the widget's exportValue (e.g. 'Red', 'Blue', 'Pass') or fall back to 'Yes'
344346
const onValue = widget.exportValue || "Yes";
345347
return (
346348
<div
@@ -433,6 +435,7 @@ function WidgetInputInner({
433435
multiple={field.multiSelect}
434436
style={{
435437
...inputBaseStyle,
438+
minWidth: "100%",
436439
padding: 0,
437440
paddingLeft: 2,
438441
appearance: "auto",

frontend/editor/src/core/tools/formFill/providers/PdfiumFormProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function toFormField(
9292
// Derive value string
9393
let value = f.value;
9494
if (type === "checkbox") {
95-
value = f.isChecked ? "Yes" : "Off";
95+
value = f.isChecked ? f.widgets[0]?.exportValue || "Yes" : "Off";
9696
} else if (type === "radio") {
9797
// Use widget index as the canonical radio value.
9898
// This avoids issues with duplicate exportValues across widgets

0 commit comments

Comments
 (0)