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.