i just tweak lighting:recordeditform
for research. since i couldn't find any where in documentation for lighting:recordeditform
doesn't support for lightning:input
so i tried with below code for set the focus for lighting:input
with in lighting:recordeditform
cmp
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes">
<aura:attribute name="newContact" type="Contact" default="{ 'sobjectType': 'Contact'}"/>
<!-- Display the new contact form -->
<div class="Create Contact">
<lightning:card iconName="action:new_contact" title="Create Contact">
<lightning:recordEditForm
onsubmit="{!c.handleSubmit}"
onerror ="{!c.handlerror}"
objectApiName="Contact">
<lightning:messages />
<lightning:inputField fieldName="AssistantName" value="{!v.newContact.AssistantName}"></lightning:inputField>
<lightning:inputField fieldName="Age__c" value="{!v.newContact.Age__c}"></lightning:inputField>
<lightning:input label="email" type="email" aura:id="emailfld" value="{!v.newContact.Email}"></lightning:input>
<lightning:button class="slds-m-top_small" variant="brand" name="update" type="submit" label="Save" />
</lightning:recordEditForm>
</lightning:card>
</div>
controller.js
({
handleSubmit: function(component, event, helper) {
// Prepare a new record from template
event.preventDefault();
var newcon = component.get("v.newContact");
var newconstr = JSON.stringify(newcon); //newconstr = "{"sobjectType":"Contact","AssistantName":"setesting","Age__c":"32"}"
component.find("emailfld").focus();
},
})