I am creating a Lightning Component (Aura) to create a child record from the parent record. The basic component worked up until I added the "recordId="{!v.recordId}"" line after <lightning:recordEditForm
. I just get an error message now that says [object object]
. Can anyone spot what I have wrong here?
The parent object is "Employee__c" and the child object is "Employee_Session__c".
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
<aura:attribute name="disabled" type="Boolean" default="false" />
<aura:attribute name="saved" type="Boolean" default="false" />
<aura:attribute name="showSpinner" type="Boolean" default="true" />
<aura:attribute name="recordId" type="String" />
<aura:if isTrue="{!v.showSpinner}">
<lightning:spinner />
</aura:if>
<aura:if isTrue="{!!v.saved}">
<lightning:recordEditForm
recordId="{!v.recordId}"
onload="{!c.handleLoad}"
onsubmit="{!c.handleSubmit}"
onsuccess="{!c.handleSuccess}"
objectApiName="Employee_Session__c"
>
<!-- the messages component is for error messages -->
<lightning:messages />
<lightning:inputField fieldName="Name" />
<lightning:inputField fieldName="Employee__c" value="{!v.recordId}" />
<lightning:inputField fieldName="Intro_with_Compliance_Verbiage__c" />
<lightning:inputField fieldName="Core__c" />
<lightning:inputField fieldName="Voluntary_Benefits__c" />
<lightning:inputField fieldName="Conclusion__c" />
<div class="slds-m-top_medium">
<lightning:button disabled="{!v.disabled}" variant="brand" type="submit" name="save" label="Create Session" />
</div>
</lightning:recordEditForm>
<aura:set attribute="else">
<p>Saved! New record id is {!v.recordId}</p>
</aura:set>
</aura:if>
</aura:component>
v.recordid
added in` recordId="{!v.recordId}"` for child record formlightning:recordEditForm
, what is your use case? that's why cmp gets confused because your parent component implemented byforce:hasRecordId