1

I have a requirement where I have a validate button for Lightning:recordEditForm on click of which it needs to update certain fields. So my code is something like this

    <lightning:recordEditForm  aura:id="recordEditForm" 
                                    recordId="{!v.myObject.Id}"
                                    onsuccess="{!c.handleSuccess}" 
                                    objectApiName="Address__c">
        <lightning:inputField fieldName="Address_Line_1_Native__c" aura:id="addrNative" onchange="{!c.fieldValChange}" />     
<lightning:button variant="brand" name="Validate" label="Validate" onclick="{!c.validate}" />                       
    </lightning:recordEditForm>

and within validate() in JS

component.find("addrNative").set("v.value", "Accounting");

This works fine as long user is not entering anything in the field,but when user updates the field and clicks on validate, the button doesn't works

Found some similar question asked

  1. Not able to set value for Lightning:inputField field if it's manually modified from UI
  2. Spring 18 : Value Attribute in lightning:inputField

The later has marked one answer as solution as well but that actually doesn't work

any suggestions?

  • your inputField is inside a loop of aura:Iteration. That mean there can be multiple inputFields with same aura:Id and when you try to set value it doesnt know to which input it should set value. Can you post the complete button click code we can figure out aw ay out. – Pranay Jaiswal Nov 5 '18 at 12:52
  • My fault!Updated the code section. Please check again – Monalisa Das Nov 5 '18 at 12:56
  • please share the whole validate() method – Itai Shmida Nov 5 '18 at 13:26
  • code is this much only – Monalisa Das Nov 5 '18 at 13:27
  • I replicated the same bug in my org as well.. looks like an issue from sf side – Pranay Jaiswal Nov 5 '18 at 14:33

Your Answer

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

Browse other questions tagged or ask your own question.