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.

  • it will be great if you can add your code as well. – Himanshu Feb 7 '18 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 . – Mohith Shrivastava Feb 7 '18 at 17:23
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");
  • 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 – Ravi Narayanan Feb 7 '18 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 . – Mohith Shrivastava Feb 7 '18 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. – Basant Kumar verma Aug 3 '18 at 11:15
  • 1
    This doesn't worked for me. I believe its not the correct answer – Monalisa Das Nov 5 '18 at 13:35

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.