You need to sign in to do that
Don't have an account?
Amit_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>
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>
https://naveendhanaraj.wordpress.com/2017/10/17/input-data-using-forms-lightning-trailhead/
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