StratusForms
StratusForms copied to clipboard
PopulateFormData() does not respect $(form) on StratusFormRepeatable's
The first argument of PopulateFormData()
is form
and as a jquery selector it is supposed to limit which fields are being populated (or at least that's how I've understood it based on how it is called through $(form).StratusFormsInitialize()
and LoadFormFields(form, ...)
and how it works with all other fields except the exception below).
In other words, if I call $(form).StratusFormsInitialize()
I expect ONLY fields that are within $(form) to be initialized.
If there is a StratusFormsRepeatable
section that is in the data but not within $(form)
then it is initialized regardless.
My fix added these lines:
if ((repeatableArray[index].StratusFormsParent !== undefined && !$(form).find("#" + repeatableArray[index].StratusFormsParent).length) || (!repeatableArray[index].StratusFormsParent && !$(form).find("#" + repeatableArray[index].ID).length)) { console.log('DBG: PFD: Jumping ship early'); continue; }
They should be placed between these 2 lines on 714-715:
for (var index in repeatableArray) { if (repeatableArray[index].StratusFormsParent != "undefined") {
There may be a more elegant way (I note that I have lost the theoretical potential of repeatables within repeatables), but this is at least one way to fix it.