I have what at first seems to be a simple question, but I can't seem to pin it down. I'm working with the lightning:recordForm, and I'm sending the fields dynamically based off a callout where I'm populating the {!v.fields}. I have tried multiple ways to structure the variable so that it will render the correct fields, but the best I seem to get is it will render the first field in the list. Documentation says the structure should be String[] and be in the form of "['Item1', 'Item2']". Maybe its my own shortcomings on the intricacies of JavaScript types, but I can't get it to work. Note that one sticking point that may be part of the issue is that my callout returns an object with a string of fields and those need to be split and stored in the list. Here are the relevant snippets of my code:
<aura:attribute name="fields" type="String[]"/>
...
<lightning:recordForm objectApiName="{!v.thisObject}"
fields="{!v.fields}"
recordTypeId="{!v.selectedRecordType}"
columns="2"
oncancel="{!c.handleCancel}"
onSubmit="{!c.handleSubmit}"
onsuccess="{!c.handleSuccess}"/>
Controller:
var fieldsList = custRecCreateList[i].Fields__c.split(",");
for(var j=0; j<fieldsList.length; j++){
fields[j] = fieldsList[j]; //I've also tried fields.push(fieldsList[j]) here
}
....
component.set("v.fields", fieldsList);
Thanks in advance for your help!