0

I have a TextField(AboutMe__c) that I am displaying on an Aura page. The user will write stuff and when they hit submit I want to save whatever they typed to Quote.AboutMe__c field. When I debug this AboutMe__c is coming up as null when I type something and hit the button. Any Ideas as to why?

Aura

<div class="slds-clearfix slds-p-around_medium">
                    <lightning:input class="About_Me" aura:id="AboutMe" min="0" step="1" 
                                    label="AboutMe" type="text"
                                    value="{!v.quote.AboutMe__c}" required="true" />
                </div>
</div>
            <div class="slds-size_1-of-4">
                <div class="slds-clearfix slds-p-around_medium">
                    <lightning:button variant="brand" label="{!$Label.c.OnSubmit}" 
                                    onclick="{!c.onSubmit}" />
                    <lightning:button variant="brand" label="Cancel" onclick="{!c.onCancel}" />
                </div>
            </div>

Javascript

 onSubmit : function(component, event, helper) {
     
       var AboutMe = component.get('v.quote.AboutMe__c');
       console.log("ManageQuote - v.quote.AboutMe__c value:", AboutMe);
        

},

1 Answer 1

1

This usually happens because the attribute is of the wrong type. The following should work:

<aura:attribute name="quote" type="Quote" default="{}" />

You can use an sObject of any type, or you can specify the type of Map, which also behaves correctly. Using something like Object or String won't work as you expect.

2
  • i change my line to <aura:attribute name="quote" type="Quote__c" default="{}" /> and it didnt work
    – CodeMonger
    Commented Feb 15 at 4:11
  • @CodeMonger We'd need to see more code. It'd be easier if I could copy paste. I did test this in my org, it's works fine.
    – sfdcfox
    Commented Feb 15 at 4:18

You must log in to answer this question.

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