I have a lightning:recordEditForm that requires two submit buttons. Submit buttons are required rather than using onclick due to submit() not firing the forms onsubmit event. This is required so that I can modify the fields payload.
Is there a way to tell within the onsubmit event which button was clicked?
I've tried the following:
event.getParam("name")
- returns undefined
event.getSource().get("v.name")
- returns undefined
event.getName()
- returns "submit" for both buttons. This makes sense.
event.getSource()
- returns something like the below, relying on the number will likely be fragile:
SecureComponentRef: markup://lightning:recordEditForm {1234:0} {recordEditForm}{ key: {"namespace":"c"}
<lightning:recordEditForm
aura:id="recordEditForm"
onload="{!c.handleLoad}"
onsubmit="{!c.handleSubmit}"
onsuccess="{!c.handleSuccess}"
recordId="{!v.RecordId}"
objectApiName="Account">
<lightning:messages />
<lightning:buttonIcon
iconName="utility:save"
title="APPROVE"
name="APPROVE"
value="APPROVE"
type="submit" />
<lightning:buttonIcon iconName="utility:save"
title="REJECT"
name="REJECT"
value="REJECT"
type="submit" />
<lightning:inputField fieldName="Name"/>
<lightning:inputField fieldName="Phone"/>
</lightning:recordEditForm>
handleSubmit : function(component, event, helper) {
console.log("param name "+event.getParam("name")); //undefined
console.log("source name "+event.getSource().get("v.name")); //undefined
console.log("param value: "+event.getParam("value")); //undefined
console.log("getSource "+event.getSource()); //SecureComponentRef: markup://lightning:recordEditForm {1234:0} {recordEditForm}{ key: {"namespace":"c"} }
console.log("getName "+event.getName()); //Submit
},