The recordEditForm
is not supposed to need the Lightning data service provided by recordData
however in the below example the only time fields beyond the first one show up are if I also include the recordData
component.
Example:
<aura:component description="Example" access="global">
<aura:attribute name="componentError" type="String" access="private"
description="An error message to display instead of the component"/>
<aura:attribute name="payeeRecordId" type="String" access="global"/>
<aura:attribute name="payeeObjectType" type="String" required="true" access="global" default="Contact"/>
<aura:attribute name="payeeRecordFields"type="Object" access="private"/>
<aura:attribute name="payeeRecordFieldList" type="String[]" access="global" default="FirstName, LastName"/>
<aura:attribute name="payeeRecord" type="Object" access="private"/>
<aura:attribute name="payeeRecordError" type="String" access="private"/>
<aura:if isTrue="{!not(empty(v.componentError))}">
<div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_error" role="alert">
<span class="slds-assistive-text">Error</span>
<span class="slds-icon_container slds-icon-utility-error slds-m-right_x-small"
title="Description of icon when needed">
<lightning:icon variant="inverse" iconName="utility:error" size="x-small"/>
</span>
<h2>{!v.componentError}</h2>
</div>
<aura:set attribute="else">
<force:recordData aura:id="payeeRecord"
layoutType="FULL"
recordId="{!v.payeeRecordId}"
targetRecord="{!v.payeeRecord}"
targetFields="{!v.payeeRecordFields}"
fields="{!v.payeeRecordFieldList}"
targetError="{!v.payeeRecordError}"
mode="VIEW"/>
<lightning:recordEditForm recordId="{!v.payeeRecordId}" objectApiName="{!v.payeeObjectType}">
<aura:iteration items="{!v.payeeRecordFieldList}" var="f">
<lightning:inputField fieldName="{!f}"/>
</aura:iteration>
</lightning:recordEditForm>
</aura:set>
</aura:if>
Output
However if I remove the force:recordData
component only the first field gets output
Goal
I am trying to provide a way for the user of the component to specify which fields get presented for input.
Best Answer
UPDATE
Based on your latest edits, you have the attribute populated as below:
Having spaces in the field names did not work for me. Later, referring to the excerpt from the documentation, seems this may have been the issue here.
This is what I think was happening in this case when being used with
force:recordData
(LDS) implementation. LDS would have taken care of removing spaces from the attributepayeeRecordFieldList
And that without LDS because the field names are separated with a comma and a space in there, it never worked because of the explanation as in documentation.In my example below, the field names worked without having spaces between it and then later with the approach as mentioned in the documentation.
You don't need a
force:recordData
implementation here. As long as your attributepayeeRecordFieldList
is populated and consists of the fields you want to display on your form, you should be able to render those fields in yourlightning:recordEditForm
.You may like to verify if the attribute
payeeRecordFieldList
is populated correctly or not.As an example, I used your code with few minor modifications and removed the
force:recordData
piece and after declaring the attribute as below, the fields were rendered appropriately.