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
Ken Koellner 1Ken Koellner 1 

Challenge Not yet complete... here's what's wrong: The campingList component doesn't have an attribute named 'newItem' of type Camping_Item__c with a default sObject.

Trying the Input Data Using forms trailhead and doing the "Create a Form to Enter New Items" at the end of one module.  Getting error --

"Challenge Not yet complete... here's what's wrong: 
The campingList component doesn't have an attribute named 'newItem' of type Camping_Item__c with a default sObject."

MY campingList.cmp file begins--
<aura:component >
    
     <aura:attribute name="newItem" type="Camping_Item__c" default = "{ 'Quantity__c' : '0'
                                                                      , 'Price__c'   : '0' }"/>
     <aura:attribute name="items" type="Camping_Item__c[]"/>
Any Idea what could be wrong?

I am using a dev org with a Namespace.  (I thought you had to do do Lighning trailheads.)

 
Best Answer chosen by Ken Koellner 1
Ken Koellner 1Ken Koellner 1
It appears that adding --
'sobjectType': 'Camping_Item__c',

to the newItem atttribute fixed that issue.

All Answers

Ken Koellner 1Ken Koellner 1
It appears that adding --
'sobjectType': 'Camping_Item__c',

to the newItem atttribute fixed that issue.
This was selected as the best answer
Gavin Britto 2Gavin Britto 2
<aura:component controller="CampingListController">
    <aura:handler name = "init" value="{!this}" action = "{!c.doInit}"/>
	<aura:attribute name="items" sobjectType="Camping_Item__c[]"/>
    <aura:attribute name="er" type="boolean" default="false"/>
    <aura:attribute name="newItem" sobjectType= "Camping_Item__c"    default="{ 'sobjectType': 'Camping_Item__c',
                         'Name': '',
                         'Price__c': 0,
                         'Quantity__c': 0,                         
                         'Packed__c': false
                       }"/>
    <ui:inputText value="{!v.newItem.Name}" aura:id="name" label="name"/>
    <ui:inputCheckbox value="{!v.newItem.Packed__c}" aura:id="Packed" label="Packed"/>
    <ui:inputCurrency value="{!v.newItem.Price__c}"  aura:id="Price" label="Price"/>
    <ui:inputNumber value="{!v.newItem.Quantity__c}" aura:id="Quantity" label="Quantity"/>
    <ui:button label="Create Expense" press="{!c.CreateCamping}" aura:id="button"/>
    <br/>
	<aura:iteration items="{!v.items}" var="PerItem">
        
        <c:campingListItem item="{!PerItem}" />
    </aura:iteration>
</aura:component>


Hi Ken,

Did I get the syntax right here?

Wade Lovell 21Wade Lovell 21
Hi Gavin,
This is a lightning module so you will be required to change all of the ui: elements to lightning, e.g. <ui:inputText... becomes <lightning:input... (lightning:input defaults to text but you can add the optional attribute type="text" if you'd like).
Hope this helps,
Wade