4

I have a function to create new form requests:

clickCreateTrainingReq: function(component, event, helper) {

        var validTrainingReq = true;

        //preparing all data
        var nameField = component.find("firstname");
        var firstname = nameField.get("v.value");

        var secondNameField = component.find("secname");
        var secname = secondNameField.get("v.value");

        //checking conditions - error checking and displaying

        if ($A.util.isEmpty(firstname)){
            validTrainingReq = false;
            nameField.set("v.errors", [{message:"First name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }

        if ($A.util.isEmpty(secname)){
            validTrainingReq = false;
            secondNameField.set("v.errors", [{message:"Second name can't be blank."}]);
        }
        else {
            secondNameField.set("v.errors", null);
        }

    if(validTrainingReq){
            // Create the new training request
            var newTraining = component.get("v.newTraining");
            console.log("Create expense: " + JSON.stringify(newTraining));
            helper.createTrainingRequest(component, newTraining);
        }

Can I clear in this function data? how to do is? when I put firstname.set("v.value", ''); it doesn't work

1 Answer 1

2

firstname variable only contains the value of nameField variable. When you use firstname.set("v.value",''); you are not setting the blank value to nameField variable.

So you should use nameField.set("v.value",NULL);. I used NULL instead of ''.

Hope it helps.

0

You must log in to answer this question.

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