How to submit a lightning:recordEditForm from a button that isn't nested?
You can manually trigger the submit action of lightning:recordEditForm
component without having to use <lightning:button type="button"/>
which can be found in the new component documentation UI : https://<myDomain>/componentReference/suite.app
Sample code:
<lightning:recordEditForm aura:id="editForm" recordId="0032800001DYoc0" objectApiName="Contact">
<lightning:messages />
<lightning:inputField fieldName="FirstName" />
<lightning:inputField fieldName="LastName" />
<lightning:inputField fieldName="Email" />
</lightning:recordEditForm>
<lightning:button class="slds-m-top_small" variant="brand" type="button" name="update" label="update" onclick="{!c.update}" />
controller:
update : function(component,event,helper) {
component.find("editForm").submit();
}
This is working as designed. onsubmit belongs to the form (or more specifically the button in the form).
The assumption is, if you are already outside of the form, i.e. you know that another button/link is going to submit the form, you can just do whatever processing you need before firing the submit method.