29 thoughts on “Rendering Lightning:RecordEditForm based on the page layout

    1. Naval Sharma Post author

      You need to check section.totalColumns value as we are using this to set the multipleColumn property.

  1. Naval Sharma Post author

    You will have to use smallDeviceSize, mediumDeviceSize, largeDeviceSize attributes on lightning:layoutItem.

  2. Bharti Harimohan


    Can you please also assist me to display page layout required fields using recordeditForm with lightning:inputField ?

  3. shravya

    Hi , I tried doing the same . it was very helpful . but for some reason the required custom fields are not required .How to handle this

  4. AshTric

    Is it possible for multiple record types ?
    If yes what are the required changes we need to make ?

  5. Simangaliso Mathenjwa

    nice work!, tell me if the field is marked as required on a page layout, will it be a required field on the component also?

      1. kapil

        please tell what is that approach to mail or post .
        Actually my requirement was to get standard page layout and account name should populate when record is being created from related list
        example i am referring the below link :https://gist.github.com/sfcure/845a0e75815f7c0d6c92baebcce5bc3d
        here in this code how can i get the account name when record is getting created from related list and when the record is getting created from the list view account lookup field should be blank or empty (where user can enter what ever he wants)

  6. Adeel Ahmad

    Great work Naval
    But i am having an issue here, Every time when i pass the page layout name it returns me null so i am unable to proceed further. Do you have any idea why it is not working or salesforce just updated the API


    1. Naval Sharma Post author

      Make sure that you are passing a correct name. If Opportunity has a page layout name “Opportunity Sales Layout” then you need to pass it like. “Opportunity-Opportunity Sales Layout”.

  7. Jerun Jose

    Thanks Naval for sharing this awesome post. Works as specified. I’m working on some minor improvements and will share the finished code when complete. You saved a few days of head scratching to get this started.

  8. Manju

    HI Naval,

    I could use this in opportunity cloning(with products) where I have to get all the fields in the layout and the corresponding values to pre-populate in the fields. What would be the approach to pre-populate values in the corresponding fields? Appreciate a quick response, I have a three days deadline 🙁


  9. Gopal Agarwal

    Hi Naval,
    Great Blog.
    What if i need to accumulate multiple layouts at once.

    Can we do so like below?

    List componentNameList = new List{‘Contact-Contact Layout’,’Contact-Contact Sales Layout’ };

    Thanks in advance

  10. Madhu

    Hi Naval,
    Nice work! nice work!, I used your approach and created the lightning component but the required fields that are on page layouts are not appearing on the lightning component as required.

    Any one here have same issue?

  11. Mayank

    Hello Naval,

    Great Work!!
    how can we get a pagelayout name dynamically instead hard coding.
    As far as i know we can not query a pagelayout using SOQL, so how we can pass pagelayout dynamically based on profile or may be user?

    1. Naval Sharma Post author

      Hi Mayank,

      Either user Metadata API or Custom Label/Custom Metadata Types for the mapping.

  12. Satish Inuganti

    I just did it if anyone has issue with columns you may use this in ur aura “!section.totalColumns >= 1”


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.