The site uses Nutshell forms. The drop-down and checkbox fields (eavEnumElements) are captured in LeadManagerFX as random string-ish values instead of the selected options. Architect requested to show the field selections legibly.
I added a custom code in WordPress’ RCFX Settings Footer that gets the selected drop-down values and checked checkboxes of each field when the form is captured.
It adds them in a hidden input with the selected labels so they can be mapped in LeadManagerFX.
I also updated the field mapping of the mapped forms to use these hidden inputs.
console.log('eavEnumElements capture ready!');
mcfx(function(t) {
t.configure("onFormCapture", function(form) {
console.log('mcfx form capture');
function addHiddenField(name, value) {
var existingInput = form.querySelector('input[name="' + name + '"]');
if (existingInput) {
form.removeChild(existingInput);
}
var hiddenInput = document.createElement('input');
hiddenInput.type = 'hidden';
hiddenInput.name = name;
hiddenInput.value = value;
form.appendChild(hiddenInput);
}
var fieldsets = form.querySelectorAll('fieldset');
for (var f = 0; f < fieldsets.length; f++) {
var fieldset = fieldsets[f];
var wfFieldsInput = fieldset.querySelector('input[type="hidden"][id$="wfFields"]');
if (!wfFieldsInput) {
continue;
}
var groupName = 'rcfx-custom-name-' + wfFieldsInput.id;
var labels = [];
var containers = fieldset.querySelectorAll("div[class*='-container']");
for (var j = 0; j < containers.length; j++) {
var divs = containers[j].querySelectorAll('div[class*="-singleValue"]');
for (var i = 0; i < divs.length; i++) {
console.log(divs[i].innerText);
labels.push(divs[i].innerText);
}
}
var checkboxes = fieldset.querySelectorAll('input[type="checkbox"]');
for (var k = 0; k < checkboxes.length; k++) {
if (checkboxes[k].checked) {
var label = checkboxes[k].parentNode;
var labelText = label ? label.textContent : '';
labels.push(labelText);
}
}
if (labels.length > 0) {
addHiddenField(groupName, labels.join(', '));
}
}
});
});
Drop-down and checkbox selections are captured in LeadManagerFX as legible labels instead of random string-ish values.
Task: Link
Code: Screenshot