1

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>
  • Your code runs fine on my machine. Could you cross checked the datatype of Packed__c. I believe it should be checkbox. – Rohit Mourya Sep 7 '17 at 8:39
4

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}" />

Not the answer you're looking for? Browse other questions tagged or ask your own question.