1

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"/>

     <lightning:recordForm 
         objectApiName="Lead"
         recordTypeId = 'xxxxxxxxxxx'
         recordId="{!v.recordId}"
         fields="{!v.fields}"
         layoutType="Full"
         mode="edit"
         onsuccess="{!c.handleSuccess}"
         oncancel="{!c.onCancel}"/> 
</aura:component>
8
  • Please share some code and explain a little better what it is you're trying to do. – AvailableName May 13 '19 at 14:10
  • What do you mean when you say modal window? Can you clarify your question a bit? – Jayant Das May 13 '19 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. – user3920709 May 13 '19 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. – AvailableName May 13 '19 at 14:24
  • 1
    The example in developer.salesforce.com/docs/component-library/bundle/… shows how to make a footer like that. – AvailableName May 13 '19 at 14:28
0

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:

MyComponent.cmp

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

MyComponentController.js

({
    handleShowModal: function(component, evt, helper) {
        var modalBody;
        $A.createComponent("c:modalContent", {},
           function(content, status) {
               if (status === "SUCCESS") {
                   modalBody = content;
                   component.find('overlayLib').showCustomModal({
                       header: "Application Confirmation",
                       body: modalBody, 
                       showCloseButton: true,
                       cssClass: "mymodal",
                       closeCallback: function() {
                           alert('You closed the alert!');
                       }
                   })
               }                               
           });
    }
})
2
  • ok, thanks and you mean c:modalContent can be my above component with lightning:recordForm I suppose . – user3920709 May 13 '19 at 15:14
  • yes, exactly what I was thinking – Brian Miller May 15 '19 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.