[SalesForce] Lightning Components Basics: Attributes and Expressions Trail

The error :

The Packed field is either not using the lightning input component,
the checked value of the item's Packed__c attribute or the correct
type of input.

My Code:

<aura:component >
    <aura:attribute name="item" type="Camping_Item__c" 
                    required="true"
                    default="{Name:'Tent', Price__c:100, Quantity__c:1, Packed__c:true}"
                    />
        <p> The Item is <ui:outputText value ="{!v.item}"></ui:outputText></p>

        <ui:outputText value="{!v.item.Name}"/>
    <lightning:input type="toggle" label="Packed" name="togglevalue" value="{!v.item.Packed__c}" />
    <lightning:formattedNumber value="{!v.item.Price__c}" style="currency" currencyCode="USD" currencyDisplayAs="symbol"/>

    <lightning:formattedNumber  value="{!v.item.Quantity__c}"/>
</aura:component>

Best Answer

Here is the problem

While using Toggle

<lightning:input type="toggle" label="Packed" name="togglevalue" value="{!v.item.Packed__c}" />

it must be corrected to checked attribute instead of value attribute

<lightning:input type="toggle" label="Packed" name="togglevalue" checked="{!v.item.Packed__c}" />
Related Topic