mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-03 05:10:16 +03:00
fix(forms): Fix checkbox export values and wide dropdown options (#7288)
Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
This commit is contained in:
co-authored by
Anthony Stirling
parent
8c00fffe18
commit
74be5bf0ad
@@ -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"
|
||||
|
||||
@@ -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
|
||||
@@ -433,6 +435,7 @@ function WidgetInputInner({
|
||||
multiple={field.multiSelect}
|
||||
style={{
|
||||
...inputBaseStyle,
|
||||
minWidth: "100%",
|
||||
padding: 0,
|
||||
paddingLeft: 2,
|
||||
appearance: "auto",
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user