I'm attempting to re-implement a form using the "Modern Forms Designer" or as it's being called now "Forms Designer" however I'm finding it difficult to repeat things which were easy to do in classic forms...
For example I have a classic form with a drop-down populated from a View which Sorts and Orders the results with header rows which I then disabled so the user could not select a header option.
... /* In Ready Fuction */
$(document).on('lookupcomplete', disableInstitutionSectionHeaders);
...
function disableInstitutionSectionHeaders()
{
$('select#Field9 option[value="=== UNIVERSITIES ==="]').attr("disabled", "disabled");
$('select#Field9 option[value="=== AGENCIES ==="]').attr("disabled", "disabled");
}
This works exactly how I expect it to in Classic Forms.
The "Modern" Forms Designer implementation:
LFForm.onLookupDone(function () {
disableInstitutionSectionHeaders();
}, {lookupRuleId: 2}); // after lookup rule 2 is done, check for Lookup_Target value.
function disableInstitutionSectionHeaders() {
console.log('in disableInstitutionSectionHeaders.');
var field38 = LFForm.findFields(f => f.fieldId == 38)[0];
if (!field38) {
console.log('Field38 not found!');
return;
}
// Update options array
field38.options = field38.options.map(option => {
if (option.value.includes('===')) {
// Return a disabled version of the option
return {
checked: option.checked,
label: option.label,
optionTrackId: option.optionTrackId,
value: option.value,
disabled: true
};
} else {
return option;
}
});
// Apply changes
LFForm.changeFieldSettings({ fieldId: 38 }, field38);
}
The JavaScript is adding {Disabled: true} to the option objects correctly, but changing the Field Settings does not result in the options being disabled on the drop-down. I've tried {disabled: "disabled"} as well, no luck.
Does anyone know what I'm doing wrong here or some other means to disable options on a Modern Form drop-down?