I have a lightning component with two input fields. But the values enter in the input form doesn't bind and record is created with empty values.


<aura:attribute name="sites" type="Site_Registration__c[]" />
<aura:attribute name="newSite" type="Site_Registration__c" access="global" default="{'sobjectType':'Site_Registration__c',
                                                                                     }" />

<input aura:id="companyName" placeholder="Company Name" class="slds-input" type="text" value="{!v.newSite.Company_Name__c}" required="true"/>

<input aura:id="projectName" placeholder="Project Name" class="slds-input" type="text" value="{!v.newSite.Project_Name__c}" required="true"/>

<lightning:button variant="brand" label="Submit" title="Submit" onclick="{!c.submitSite}" />

Controller JS

submitSite : function(component, event, helper) {

    var newSiteReg = component.get("v.newSite");         

    console.log("Site Info Controller " + JSON.stringify(newSiteReg));


Helper JS

    insertSiteRegHelper : function(component,siteReg) {

     var action= component.get("c.populateSiteReg");

        action.setParams({"siteReg" : siteReg
     action.setCallback(this, function(response)
        var state = response.getState();
        if (state === "SUCCESS") 

            var sites = component.get("v.sites");
            component.set("v.sites", sites);

Apex Controller

    public static void populateSiteReg(Site_Registration__c siteReg)

        if(siteReg != null){

Any values entered to the Company Name and Project Name fields are not getting save to the record and record is creating with only value in the Name field. Any idea what is wrong here? Your comments are greatly appreciated as I'm stuck here for few days. Thanks...!

1 Answer 1


Its because you are using HTML tag. So you need to manually get the data from Lightning and pass it in the controller. It's quite similar with VF where if we used HTML tag then we need to pass that data manually in controller.

You can use Lightning tag in that you will get the data and you don't need to worry about this. Here is a sample for you.

<lightning:input name="input8" value="{! v.firstName }" placeholder="type your first name..." label="Text field with attribute binding" />

You must log in to answer this question.

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