You need to sign in to do that
Don't have an account?
Basant Kr Verma
Not able to set value for Lightning:inputField field if it's manually modified from UI
Hi All,
I am facing issue with Lightning:inputField with lightning:recordEditForm that when I am trying to programatically change the value of any field I am able to do only if user is not modifying that field manully on screen
What I mean is that, lets say I have a form using lightning:recordEditForm with only two fields of account which are Name and Type.
And I want a logic to introduce that, I want to add selected Type as Prefix on the Name field, I have created a on change method and doing it in that, and that is working as expected if user only changing the Type field
BUT if user first edit the Name field then select/change the Type its not.
Below is the my sample code
CustomRecordEditForm.cmp
CustomRecordEditFormController.js
Thanks in Advance!
I am facing issue with Lightning:inputField with lightning:recordEditForm that when I am trying to programatically change the value of any field I am able to do only if user is not modifying that field manully on screen
What I mean is that, lets say I have a form using lightning:recordEditForm with only two fields of account which are Name and Type.
And I want a logic to introduce that, I want to add selected Type as Prefix on the Name field, I have created a on change method and doing it in that, and that is working as expected if user only changing the Type field
BUT if user first edit the Name field then select/change the Type its not.
Below is the my sample code
CustomRecordEditForm.cmp
<aura:component implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,force:hasRecordId" access="global"> <aura:attribute name="recordId" type="String"/> <div class="slds-container-outer"> <div class="slds-container"> <lightning:recordEditForm aura:id="recordViewForm" objectApiName="Account" recordId="{!v.recordId}"> <lightning:messages /> <lightning:inputField fieldName="Name" aura:id="Name" /> <lightning:inputField fieldName="Type" aura:id="Type" onchange="{!c.handleTypeChange}"/> </lightning:recordEditForm> </div> </div> </aura:component>
CustomRecordEditFormController.js
({ handleTypeChange : function(component, event, helper) { var typeValue = component.find("Type").get("v.value"); var nameValue = component.find("Name").get("v.value"); if(typeValue != null && typeValue != '' && typeValue != undefined){ if(nameValue.indexOf(":") > 0){ nameValue = nameValue.split(':')[1]; } component.find("Name").set("v.value",typeValue+":"+nameValue); } } })
Thanks in Advance!
Updated CustomRecordEditFormController.js cod is as below
https://salesforce.stackexchange.com/questions/207346/spring-18-value-attribute-in-lightninginputfield/227674#227674