Component :
<aura:if isTrue="{!v.internal}">
<lightning:layoutItem size="6" padding="horizontal-small">
<lightning:inputField fieldName="To__c" class = "customRequired" value = "{!v.mailTo}" required="true"/>
</lightning:layoutItem>
</aura:if>
<aura:if isTrue="{!v.external}">
<lightning:layoutItem size="6" padding="horizontal-small">
<lightning:inputField fieldName="ToExternal__c" class = "customRequired" value = "{!v.mailExtTo}" required="true"/>
</lightning:layoutItem>
</aura:if>
Helper :
var toMail = ponent.get("v.mailTo");
var toExtMail = ponent.get("v.mailExtTo");
Why is it ing undefined, even if I populate some value in the form?
Component :
<aura:if isTrue="{!v.internal}">
<lightning:layoutItem size="6" padding="horizontal-small">
<lightning:inputField fieldName="To__c" class = "customRequired" value = "{!v.mailTo}" required="true"/>
</lightning:layoutItem>
</aura:if>
<aura:if isTrue="{!v.external}">
<lightning:layoutItem size="6" padding="horizontal-small">
<lightning:inputField fieldName="ToExternal__c" class = "customRequired" value = "{!v.mailExtTo}" required="true"/>
</lightning:layoutItem>
</aura:if>
Helper :
var toMail = ponent.get("v.mailTo");
var toExtMail = ponent.get("v.mailExtTo");
Why is it ing undefined, even if I populate some value in the form?
Share edited Aug 22, 2020 at 4:15 Herohtar 5,6234 gold badges33 silver badges42 bronze badges asked Oct 18, 2019 at 19:26 Sakshi KSakshi K 271 gold badge2 silver badges5 bronze badges 1-
maybe post the entire ponent. Do you have any
<aura:attribute>
tags for 'mailTo' and 'mailExtTo'? – KDH Commented Oct 19, 2019 at 22:56
1 Answer
Reset to default 2It's hard to know what the problem is without the entire ponent code. Do you have 'aura:attribute' tags for these fields? If you don't then I believe using ponent.get("v.mailTo");
will not work as it is attempting to get an attribute that just doesn't exist. To get the value of the input field directly you could try adding the aura:id="someId"
attribute to the <lightning:inputfield/>
tags and then access them this way:
var toMail = ponent.find("someId").get("v.value");
so you could try that out.