2

i am trying to set value to the lightning:inputField using the value attribute. The value attribute seems to work during the init handler event of the component. however i have a onchange for lightning:select . i want to set a custom value to the lightning:inputField(example, component.find("name").set("v.value","testing")). but it doesnt seem to work. however i noticed from console.log, the value attribute is getting changed but it doesnt reflect neither in UI nor while saving to the DB.

2
  • it will be great if you can add your code as well.
    – Himanshu
    Feb 7, 2018 at 17:09
  • 1
    The value attribute seems to be one way binded and not exposed .My initial examination concluded on that .You might just want to raise the case with support to see if this is something they will expose or plan to fix in later releases . Feb 7, 2018 at 17:23

1 Answer 1

2

Finally i got the value attribute to be working.

We have to Set the fieldName attribute and also the value attribute.

component.find("Name").set("v.fieldName","Name");
component.find("Name").set("v.value","Testing Name");
4
  • 1
    Thanks bro.. there is also something component.find(xxx).updateDependentField.. i am not sure what is this being used for. couldnt find documentation too Feb 7, 2018 at 17:57
  • I think for this the docs are definitely incomplete and hope Someone from salesforce updates to reflect what can be done here . Feb 7, 2018 at 22:44
  • 2
    This is still not working, I tried to set both "fieldName" (with field's API name) and "value" (with my custom value) but have no impact. Aug 3, 2018 at 11:15
  • 1
    This doesn't worked for me. I believe its not the correct answer Nov 5, 2018 at 13:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .