0

I'm using lightning:recordEditForm and lightning:inputField. I know that event.getParam('change') return updated value. but I want to get fieldName of inputField which is updated.

thank you.

        <lightning:recordEditForm
            recordId="a00R0000000jq5eIAA"
            objectApiName="Bad_Guy__c">

            <lightning:inputField  aura:id="sameId" fieldName="Name" onchange="{!c.change}"/>
            <lightning:inputField  aura:id="sameId" fieldName="Has_Weakness__c" onchange="{!c.change}"/>
        </lightning:recordEditForm>
1

TLDR : event.getSource().get("v.fieldName") or component.find("auraId").get("v.fieldName")

If you want to fetch fieldName based on aura:id then component.find would return an array, where you can use

change : function(component, event, helper) {
    console.log(component.find("sameId")[0].get("v.fieldName"))  //Name
    console.log(component.find("sameId")[1].get("v.fieldName"))  //Has_Weakness__c
}

But the best way would be using event.getSource() as it provides exact fieldName based on input field

change : function(component, event, helper) {
    console.log(event.getSource().get("v.fieldName"))
}
| improve this answer | |
  • This is the answer I was looking for ! Thank you very much. – S Kawasaki Nov 1 '19 at 0:24

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.