Resetting Record Edit Form In LWC

Hello Trailblazers !!!!

Using Record Edit Form saves a lot of time when we know there are certain fields for insertion of Record for a object. We can also reset the form on click of button as well.

       <lightning-input-field field-name="Name"></lightning-input-field>
       <lightning-input-field field-name="Industry"></lightning-input-field>
       <div class="slds-m-top_medium">
           <lightning-button class="slds-m-top_small" label="Cancel" onclick={allowReset}></lightning-button>
           <lightning-button class="slds-m-top_small" type="submit" label="Save Record"></lightning-button>
allowReset(event) {
   const inputFields = this.template.querySelectorAll(
   if (inputFields) {
       inputFields.forEach(field => {

So this works when we have all input field as ‘lightning-input-field’. In case there is some different input tag used then we can retrieve those differently and can reset them as above .

Hope this helps !!!!!

Happy Reading 🙂

2 thoughts on “Resetting Record Edit Form In LWC

Leave a Reply to Rahul Gupta Cancel reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s