Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form Object RadioNodeList element fix #6

Merged
merged 1 commit into from
Mar 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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