function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amit_TripathiAmit_Tripathi 

Trail Head Lightning Component Basics- Input Data Using Forms

Getting Below error, component is working fine but cant complete the challenge. Any help is appreciated.

Error- Challenge Not yet complete... here's what's wrong: 
The campingList component either does not have an attribute named 'newItem' or it is not defined correctly. It should default to a Camping_Item__c object with the price and quantity set to 0.

Below is the Markup for camping list:

<aura:component >
    <aura:attribute name="items" type="Camping_Item__c[]"/>    
    
    <aura:attribute name="newItem" type="Camping_Item__c"  
                    default="{'sobjectType':'Camping_Item__c',                              
                                  'Name':'',
                                   'Quantitiy__c':0,
                                  'Price__c':0,                                  
                                  'Packed__c':false }"/>
    
    
    
    <!--<ol>
        <li>Bear Repellant</li>
        <li>Bug Spray</li>
        <li>Goat Food</li>
    
    </ol>-->
    
    <lightning:layout >
        
        <fieldset class="slds-box slds-theme--default slds-container--small">
            
            <legend class="slds-text-heading--small">
                
                Add Camping
            
            </legend>
            
            <form class="slds-form-stacked">
                
                <lightning:input aura:id="campingform"
                                 label="Name"
                                 name="name"
                                 value="{!v.newItem.Name}"
                                 required="true"/>
                
                <lightning:input aura:id="campingform"
                                 type="number"
                                 label="Price"
                                name="price"
                                value="{!v.newItem.Price__c}"
                                min="0.1"
                                formatter="currency"
                                step=".01"
                                 messageWhenRangeUnderflow="Enter amount greater than $.10"/>              
                                
                <lightning:input aura:id="campingform"
                                label="Quantity"
                                name="quantity"
                                value="{!v.newItem.Quantity__c}"
                                min="1"
                                type="number" messageWhenRangeUnderflow="Enter minimuim 1 Quantity"/>
                                
                 <lightning:input aura:id="campingform" 
                                  label="Packed"
                                  name="packed"
                                  value="{!v.newItem.Packed__c}"
                                  type="checkbox"/>
                
                <lightning:button label="Create Camping Item" 
                              class="slds-m-top--medium"
                              variant="brand"
                              onclick="{!c.clickCreateItem }"/>
            
            </form>
        
        
        </fieldset>
    
    
    </lightning:layout>

    <lightning:card title="Camping Item">
        <p class="slds-p-horizontal--small">
            
            <aura:iteration items="{!v.items}" var="item">
                <c:campingListItem item="{!item}"/>
            </aura:iteration>
            
        </p>
     
     </lightning:card>   
    
</aura:component>
 
Raj VakatiRaj Vakati
You can find code here 
https://naveendhanaraj.wordpress.com/2017/10/17/input-data-using-forms-lightning-trailhead/
Duncan_StewartDuncan_Stewart
Hi Amit -- well, I see an issue in the attribute definition - 'Quantitiy__c' has an extra 'i' before the 'y'.  

I ran into a similar problem, and it's extra tricky to track down since we don't really seem to be using that attribute -- I managed to define the fields as 'Quantity' and 'Price' w/o the '__c', and the form worked just fine til I hit [Check Challenge].

Thanks for posting your code - it often requires another few sets of eyes to track these things down!

Duncan
<aura:attribute name="newItem" type="Camping_Item__c"  
                    default="{'sobjectType':'Camping_Item__c',                              
                                  'Name':'',
                                   'Quantitiy__c':0,
                                  'Price__c':0,                                  
                                  'Packed__c':false }"/>