+ Start a Discussion
Andrew Hoban 6Andrew Hoban 6 

Lightning:RecordEditForm - Set values to null after form submission

Hi,

I have a Lightning:RecordEditForm that creates a record after the form has been submitted. Once the form has been saved, I require the values on the form to be set back to null, as multiple responses are reuqired without the page refreshing.

I have currently tried giving the lightning:inputField an aura id the setting that value to null within the onSuccess method but the value remains.

I have also tried e.force:refreshView but again the submitted value is present.

Component:
<lightning:recordEditForm aura:id="incidentForm" onsubmit="{!c.onRecordSubmit}" onsuccess="{!c.afterSubmit}" onload="{!c.onLoad}" objectApiName="Case" recordTypeId="0120c000001FwVPAA0">

    <lightning:inputField fieldName="Subject" aura:id="input_Subject" />
    
    <div class="slds-m-top_medium">
        <lightning:button disabled="{!v.disabled}" variant="brand" type="submit" name="save" label="Add" />
    </div>
</lightning:recordEditForm>

Controller:
//Submit Incident
    onRecordSubmit: function(component, event, helper) {        
        event.preventDefault(); // stop form submission
        
        var eventFields = event.getParam("fields");
        component.find('incidentForm').submit(eventFields);
        helper.fireRefreshEvt(component); 
    },

//On Success - After Incident Added 
    afterSubmit : function (component, event, helper) {
        component.find("input_Subject").set("v.value", "");      
        helper.getIncidents(component);
    },

Helper:
fireRefreshEvt : function(component) {
        var refreshEvent = $A.get("e.force:refreshView");
        if(refreshEvent){
            refreshEvent.fire();
        }
    }


 
Chandra Sekhar CH N VChandra Sekhar CH N V
Can you try 'NULL' in component.set instead of "" 
Andrew Hoban 6Andrew Hoban 6
Hi, still no luck. The previous value is still present.