Problem : In lightning-record-edit-form handleSubmit is not getting called
Details : Below is the code and when user clicks on "Update Opportunity" record is getting saved but nor handleSubmit nor handleSuccess is getting fired.
HTML
<template>
<lightning-card title="Opportunity Update">
<lightning-record-edit-form object-api-name="Opportunity" record-id="<HardCodedId>">
<lightning-messages>
</lightning-messages>
<lightning-input-field field-name="Name"></lightning-input-field>
<lightning-input-field field-name="AccountId"></lightning-input-field>
<lightning-button
class="slds-m-top_small"
type="submit"
label="Update Opportunity">
</lightning-button>
</lightning-record-edit-form>
</lightning-card>
</template>
JavaScript
import { LightningElement } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class updatedeal extends LightningElement {
handleSubmit(event){
event.preventDefault(); // stop the form from submitting
const fields = event.detail.fields;
console.log('Fields -->',fields);
this.template.querySelector('lightning-record-edit-form').submit(fields);
}
handleSuccess(event) {
const evt = new ShowToastEvent({
title: 'Success',
message: 'Opportunity is update successfully',
variant: 'success'
});
this.dispatchEvent(evt);
}
}
If you have any pointer let me know.