0
 success : function(component,event,helper){
        $A.get('e.force:refreshView').fire();
    },
    
    isRefreshed: function(component, event, helper) {
        location.reload();

this is what I'm using but it refreshes the whole page moving it away from my component after I save is there another way to reload the component and not the whole page if not then just a way to refresh the view of </lightning:recordEditForm> so after the record is created the form is blank again without reloading the whole page

1
  • The Aura framework doesn’t have a “refresh component” functionality you’ll need to handle that on your own. The easiest way is to call your init method again if you have one and set aura attributes back to their default values. Not the most efficient but usually does the trick. Commented Oct 5, 2021 at 21:17

1 Answer 1

1

The documentation for <lightning:recordEditForm> shows how to reset the form, under the section Resetting the Form:

To reset the form fields to their initial values, use the reset() method on lightning:inputField.

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId">
    <lightning:recordEditForm objectApiName="Account" recordId="{!v.recordId}">
        <lightning:messages />
        <lightning:inputField aura:id="field" fieldName="Name" />
        <lightning:inputField aura:id="field" fieldName="Industry" />

            <div class="slds-m-top_medium">
            <lightning:button label="Cancel" onclick="{!c.handleReset}" />
            <lightning:button type="submit" label="Save Record" />
        </div>
    </lightning:recordEditForm>
</aura:component>

Call the reset() method on each field.

({
    handleReset: function(cmp, event, helper) {
        cmp.find('field').forEach(function(f) {
            f.reset();
        });
    }
})

What you are doing is asking your web browser to reload the page.

1
  • thanks couldn't find a different way before
    – Guest
    Commented Oct 6, 2021 at 0:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .