function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vivek Kumar 257Vivek Kumar 257 

How to create a form fieldset via creating dynamic fields in lightning component?

MagulanDuraipandianMagulanDuraipandian
Vote for this idea to be delivered for this issue

https://success.salesforce.com/ideaView?id=08730000000E1UKAA0
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
If you want to create lightning with dynamic fields, retrieve the fieldset fields from server side and use lightning:recordEditForm
<lightning:recordEditForm objectApiName="Contact">
        <lightning:messages />
        <lightning:inputField fieldName="FirstName" />
        <lightning:inputField fieldName="LastName" />
        <lightning:inputField fieldName="Email" />
        <lightning:inputField fieldName="AccountId" value="0011p00001ZQDGzAAP"/>
        <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" />
    </lightning:recordEditForm>
This can be changed to
<aura:attribute name="fieldsAPIList" type="List"/>

<lightning:recordEditForm objectApiName="Contact">
         <aura:iteration items="{!fieldsAPIList}" var="fieldAPIName">
               <lightning:inputField fieldName="{!fieldAPIName}"/>
         </aura:iteration>
</lightning:recordEditForm>
But yes there are few issues with lightning:recordEditForm when used with Master-Detail field (without reparenting)