function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jamie StudzinskiJamie Studzinski 

Lightning Input Date not binding to Date Field

I'm having issues getting lightning:input type=date to bind to a date field. Any suggestions? I even select a date and it never shows up in the input box

<aura:component>
    <aura:attribute name="applicant" type="Object"/>
    <aura:attribute name="applicantFields" type="Object" />
    <aura:attribute name="error" type="String"/>
    <force:recordData aura:id="applicantRecord" targetRecord="{!v.applicant}" targetFields="{!v.applicantFields}" targetError="{!v.error}" layoutType="FULL" mode="EDIT"/>
    <lightning:recordEditForm objectApiName="Applicant__c">
        <div class="slds-grid">
            <lightning:input label="First Name" value="{!v.applicantFields.FirstName__c}"/>
            <lightning:input label="Last Name" value="{!v.applicantFields.LastName__c}"/>
            <lightning:input type="email" label="Email" value="{!v.applicantFields.Email__c}"/>
        </div>
        <div class="slds-grid">
            <lightning:inputField fieldName="PlacementState__c" value="{!v.applicantFields.PlacementState__c}"/>
        </div>
        <div class="slds-grid">
            <lightning:input type="checkbox" label="Ref1" checked="{!v.applicantFields.Reference1__c}" labelClass="uiLabel-top"/>
            <lightning:input type="checkbox" label="Ref2" checked="{!v.applicantFields.Reference2__c}"/>
            <lightning:input label="Bill Rate" value="{!v.applicantFields.BillRate__c}"/>
            <lightning:input label="Pay Rate" value="{!v.applicantFields.PayRate__c}"/>
        </div>
        <div class="slds-grid">
            <lightning:input type="date" label="Start Date" value="{!v.applicantFields.StartDate__c}"/>
            <lightning:input type="date" label="End Date" value="{!v.applicantFields.EndDate__c}"/>
        </div>
        <lightning:button label="Save" onclick="{!c.save}"/>
        <div>
            {!v.error}
        </div>
    </lightning:recordEditForm> 
</aura:component>   
Raj VakatiRaj Vakati
You need to sepcifi the record id  .. try this code
 
<force:recordData aura:id="applicantRecord" targetRecord="{!v.applicant}" recordId="{!v.recordId}" targetFields="{!v.applicantFields}" targetError="{!v.error}" layoutType="FULL" mode="EDIT"/>

Complete code
 
<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName">
    <aura:attribute name="applicant" type="Object"/>
    <aura:attribute name="applicantFields" type="Object" />
    <aura:attribute name="error" type="String"/>
    <force:recordData aura:id="applicantRecord" targetRecord="{!v.applicant}" recordId="{!v.recordId}" targetFields="{!v.applicantFields}" targetError="{!v.error}" layoutType="FULL" mode="EDIT"/>
    <lightning:recordEditForm objectApiName="Account">
        <div class="slds-grid">
            <lightning:input label="Account" value="{!v.applicantFields.Active__c}"/>
            <lightning:input label="AnnualRevenue" value="{!v.applicantFields.AnnualRevenue}"/>
        </div>
        
        <div class="slds-grid">
            <lightning:input type="date" label="Start Date" value="{!v.applicantFields.SLAExpirationDate__c	}"/>
            <lightning:input type="date" label="End Date" value="{!v.applicantFields.EndDate__c}"/>
        </div>
        <lightning:button label="Save" onclick="{!c.save}"/>
        <div>
            {!v.error}
        </div>
    </lightning:recordEditForm> 
</aura:component>

 
Jamie StudzinskiJamie Studzinski
Everything else binds correctly, just not the date fields. Record Id doesn't need to be specified 
Raj VakatiRaj Vakati
My mistake ..  i am looking into it.. please checj  Can you check below potions .. 

Are you getting the data into the StartDate__c fields ? or DO you have access for the fields .. 
Jamie StudzinskiJamie Studzinski
Yes I am. There is data in there, it's not showing. The lightnining:input type=date won't even display the date I select
Raj VakatiRaj Vakati
Can u send me a screenshoot pls 
Jamie StudzinskiJamie Studzinski
I mean it would just be an empty input box. Don't think a screenshot would help you more than code :D