Skip to content

Commit

Permalink
Merge pull request #13933 from brendandahl/xfa-checkbox2
Browse files Browse the repository at this point in the history
Fix saving of XFA checkboxes. (bug 1726381)
  • Loading branch information
timvandermeij authored Aug 27, 2021
2 parents b0929dc + 6d2193a commit 153d058
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/core/xfa/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,8 @@ class CheckButton extends XFAObject {
field.items.children[0][$toHTML]().html) ||
[];
const exportedValue = {
on: (items[0] || "on").toString(),
off: (items[1] || "off").toString(),
on: (items[0] !== undefined ? items[0] : "on").toString(),
off: (items[1] !== undefined ? items[1] : "off").toString(),
};

const value = (field.value && field.value[$text]()) || "off";
Expand Down Expand Up @@ -1296,6 +1296,7 @@ class CheckButton extends XFAObject {
type,
checked,
xfaOn: exportedValue.on,
xfaOff: exportedValue.off,
"aria-label": ariaLabel(field),
},
};
Expand Down
6 changes: 5 additions & 1 deletion src/display/xfa_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ class XfaLayer {
break;
}
html.addEventListener("change", event => {
storage.setValue(id, { value: event.target.getAttribute("xfaOn") });
storage.setValue(id, {
value: event.target.checked
? event.target.getAttribute("xfaOn")
: event.target.getAttribute("xfaOff"),
});
});
} else {
if (storedData.value !== null) {
Expand Down

0 comments on commit 153d058

Please sign in to comment.