I have a datatable component nested inside my recordEditForm to display and edit some data (and never submitting, thus the suppressBottomBar="true"). The weird thing is that whenever a user does an inline edit on the datatable, the onsubmit() for the recordEditForm is immediately called. Is there a solution to either preventing the onsubmit() from calling altogether or having a way to find the origin of the onsubmit() call (coming from a datatable inline edit) and then canceling the submission?

There is already a same question in the forum but it had no answer so had to post this question again.

Also, it is necessary to keep this datatable in the record edit form because of some existing design issues.

Below is the code snippet

<lightning:recordEditForm aura:id="mainForm"
  data="{! v.data }"
  columns="{! v.columns }"
<!-- Submit button also here-->
  • Can you use even.getSource() to see if it was fired by the table? Does the datatable render any button elements without type attribute? If so then the form may be submitting because clicking any button inside a form triggers the submission. This is probably not what you want to hear, but I think you should really move that table outside of the form. – adriancg May 20 '20 at 16:43
  • datatable does render a lightning button but issue is the inline edit. On clicking of any cell in a row to edit, control is transfered to recordeditform and form is submitted @adriancg – SFDCBug May 20 '20 at 17:42
  • You mean when clicking the pencil to edit a cell? That pencil is a button element without a type attribute, so when you click it it will submit the form. That's just regular html at work. Try this and watch it submit when you click the button <form><button>Hello</button></form> – adriancg May 20 '20 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.