Okay, I am using lightning:recordForm to create a standard contact form in which I am redirecting on cancel and on success using lightning:navigation but since the layout in recordForm is not that good and since there is no such layout like standard. Now, I am thinking to use modal window but I guess I cannot use lightning:recordForm . Am I wrong ? Can someone please correct me ?

<aura:component >
    <aura:attribute name="accountId" type="String" />
    <aura:attribute name="recordId"  type="String" />   
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <lightning:overlayLibrary aura:id="popuplib"/>
    <aura:attribute name="url" type="String"/>
    <lightning:navigation aura:id="navService"/>
    <aura:attribute name="pageReference" type="Object"/>
    <aura:attribute name="fields" type="String[]" default="['Account__c']" />
    <lightning:notificationsLibrary aura:id="notifLib"/>

         recordTypeId = 'xxxxxxxxxxx'
  • Please share some code and explain a little better what it is you're trying to do. May 13, 2019 at 14:10
  • What do you mean when you say modal window? Can you clarify your question a bit?
    – Jayant Das
    May 13, 2019 at 14:20
  • ok, What I mean is when I use recordForm the I get the layout as Full or compact but I want the form to be displayed as standard new lead layout form. So, I was thinking on using lightning:overlayLibrary. May 13, 2019 at 14:22
  • You can put a recordForm inside the modal. Then use buttons in the footer to capture and handle the Save and Cancel clicks. May 13, 2019 at 14:24
  • 1
    The example in developer.salesforce.com/docs/component-library/bundle/… shows how to make a footer like that. May 13, 2019 at 14:28

1 Answer 1


You can use the lightning:overlayLibrary to create the modal and dynamically call your custom component.

Examples taken directly from the documentation and will work if your aura component is called modalContent:


    <lightning:overlayLibrary aura:id="overlayLib"/>
    <lightning:button name="modal" label="Show Modal" onclick="{!c.handleShowModal}"/>


    handleShowModal: function(component, evt, helper) {
        var modalBody;
        $A.createComponent("c:modalContent", {},
           function(content, status) {
               if (status === "SUCCESS") {
                   modalBody = content;
                       header: "Application Confirmation",
                       body: modalBody, 
                       showCloseButton: true,
                       cssClass: "mymodal",
                       closeCallback: function() {
                           alert('You closed the alert!');
  • ok, thanks and you mean c:modalContent can be my above component with lightning:recordForm I suppose . May 13, 2019 at 15:14
  • yes, exactly what I was thinking May 15, 2019 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.