Okay - I'm working on a travel form. I'm using items in a collection to represent individual days.
For each day - the user can specify - is this day 'Local Travel' or 'Overnight' to indicate being part of an overnight trip. When the user does pick Overnight - I want to automatically create a new item in the collection, and to increment the one of my date fields in the collection for the new row, referencing row()-1.
With jQuery this is a piece of cake. With LFForms either my understanding of the library is wrong, or it's just not listening to the DOM. I'm losing it.
Here's my code:
// The corrected version of your initial attempt
LFForm.onFieldChange(function(event) {
// The event object provides the specific value that changed
if (event.value === "Overnight") {
// Add set to the collection named 'Travel_Date_3'
LFForm.addSet({variableName: "Travel_Date_3"}, 1);
}
// Associate the listener ONLY with the field being changed: 'Travel_Type'
}, {variableName: "Travel_Date_3.Travel_Type"});
I've tried with the variable name both WITH and WITHOUT the collection name as prefix. It's not working. And I wish I could enable the console while in test/preview mode just so I could actually debug. It'd be nice to know what the options are here.
Thanks!