0

I'm using lightning:recordEditForm and lightning:inputField to create new record. But I want to setup my field is automatically:

<lightning:inputField fieldName="{! v.myField}" value="{! v.myValue}" />

But when I set myField to another field with the same fieldType, my inputField not change. I found a solution but I think it's not correct: I set myField to null before and after that, using timeout to set myField to new Field:

cmp.set("v.myField", null);
window.setTimeout(
    $A.getCallback(function() {
         cmp.set("v.myField", "newField");
    }), 1000
);

What's the best solution or what wrong I met ?

  • Can you clarify what you mean when you say:- I want to setup my field is automatically: and when I set myField to another field with the same fieldType, my inputField not change? – sanket kumar Jun 19 at 8:11
  • Example: Object MyObject__c has two field: FirstName__c, LastName__c. In init, I set myField = FirstName__c => render inputField right. After that, I do an action, like a click a button, or checkbox, ... and that action's purpose is change myField to LastName__c. Basically we use cmp.set("v.myField", "LastName__c"); But inputField not change. – Nguyễn Thắng Jun 19 at 8:56

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.