I'm finding the component.set
method only works on lightning:inputField
components when the user has not changed the value in that field. See code example below.
Component:
<lightning:recordEditForm aura:id="editForm" objectApiName="Account" recordId="0010G00002JEU4OQAX" >
<lightning:inputField fieldName="Rating" onchange="{!c.setDemoValue}" />
<lightning:inputField aura:id="nom" fieldName="Name" />
</lightning:recordEditForm>
Controller:
({
setDemoValue : function(component, event, helper) {
console.log('before value: ', component.find('nom').get('v.value'));
component.find("nom").set("v.value", "temp");
console.log('after value: ', component.find('nom').get('v.value'));
}
})
If you change the "Rating" once, you can see the code work as expected. In the javascript console you can see it log out:
before value:
after value: temp
Now change the Name field from "temp" to "hello world", and change the rating again.
before value: hello world
after value: hello world
This seems like a defect to me (I would expect after value to be "temp"), but im not sure if there is a workaround or if I am doing something wrong. Thanks!