Skip to content

Commit

Permalink
Form Object RadioNodeList element fix
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Mar 4, 2021
1 parent d9d2d6f commit a103b3b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/mf-conditional-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,18 @@ const mfConditionalFields = (forms, options = {}) => {
} else {
for (let r = 0; theRules.length > r; r++) {
if ("field" in theRules[r]) {
let theField = forms[formIndex].elements[theRules[r]['field']];
if (typeof theField !== "undefined") {
delete theRules[r]['field'];
theField.setAttribute("data-conditional-rules", JSON.stringify(theRules[r]));
newConditionalFields.push(theField);
let theFields = forms[formIndex].elements[theRules[r]['field']];
theFields = (theFields instanceof RadioNodeList)
? Array.from(theFields)
: [theFields];
for (let f = 0; theFields.length > f; f++) {
if (typeof theFields[f] !== "undefined") {
let theField = theFields[f];
theField.setAttribute("data-conditional-rules", JSON.stringify(theRules[r]));
newConditionalFields.push(theField);
}
}
delete theRules[r]['field'];
}
}
// clean `theRules` variable since we'll not need it anymore
Expand Down

0 comments on commit a103b3b

Please sign in to comment.