5

I am creating a lightning component which shows opportunity in edit mode using lightning:recordform tag(summer 18 salesforce release). Now when I am clicking on cancel button it should close the quick action dialogue but it is displaying the same record in view mode on same quick action dialogue.

Edit form using lightning:recordform

After clicking cancel button on screen

code sample :

<lightning:recordForm 
     recordId="{!v.recordId}" 
     objectApiName="Opportunity" 
     layoutType="Full" 
     columns="2"
     mode="edit"
     onsubmit="{!c.handleSubmit}"/>
5

You need to add "oncancel" as an attribute:

<lightning:recordForm 
 recordId="{!v.recordId}" 
 objectApiName="Opportunity" 
 layoutType="Full" 
 columns="2"
 mode="edit"
 onsubmit="{!c.handleSubmit}"
 oncancel="{!c.handleCancel}"/>

For some reason it is not in their documentation which can be found here but it works for me!

Hopefully this solves your issue.

0

You need to implement lightning:recordEditForm specifically and manually handle the cancel button with a lightning:button.

Per the current spec, there isn't a way to override the default actions within lightning:recordForm.

Edit: This is theoretical, I don't know if this will work but it could

Given the following setup:

<aura:attribute name="formMode" type="String" default="edit"/>

<lightning:recordForm 
     recordId="{!v.recordId}" 
     objectApiName="Opportunity" 
     layoutType="Full" 
     columns="2"
     mode="{! v.formMode }"
     onsubmit="{!c.handleSubmit}"/>

<aura:handler name="change" value="{! v.formMode }" action="{! c.handleFormModeChange }"/>

You might be able to listen to a mode change and fire the close event manually. I bet you're going to get a bit of lag though since it takes a millisecond for the change handler to process.

  • 2
    it doesn't work for me – Aequitas Jul 25 '18 at 3:02

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.