You need to sign in to do that
Don't have an account?

I am stuck in Connect Components with Events Trailhead challange
Hello everyone, I'm stuck at the last component challenge Aura,
I managed the challenge but when I try to insert a form in the database it makes me mistakes.
I tested with two submitform function
CampingListFormController.js
for the first function SubmitForm (with only one "m" at the end) i have as error :
Action failed: c:campingListForm$controller$submitForm [Cannot read property 'get' of undefined] Failing descriptor: {c:campingListForm$controller$submitForm}
for the second function SubmitFormm (with two"m" at the end) i have as error :
Action failed: c:campingListForm$controller$submitFormm [component.getItem is not a function] Failing descriptor: {c:campingListForm$controller$submitFormm}
There is my campingListFormHelper.js
I managed the challenge but when I try to insert a form in the database it makes me mistakes.
I tested with two submitform function
CampingListFormController.js
({ submitForm: function(component, event, helper) { if(helper.validateItemForm(component)){ // Create the new item var newItem = component.get("v.newItem"); helper.addItem(component, newItem); } }, submitFormm: function(component, event, helper) { var validExpense = component.find('campingform').reduce(function (validSoFar, inputCmp) { // Displays error messages for invalid fields inputCmp.showHelpMessageIfInvalid(); return validSoFar && inputCmp.get('v.validity').valid; }, true); // If we pass error checking, do some real work if(validExpense){ // Create the new expense var newItem = component.get("v.newItem"); helper.addItem(component, newItem); } } })
for the first function SubmitForm (with only one "m" at the end) i have as error :
Action failed: c:campingListForm$controller$submitForm [Cannot read property 'get' of undefined] Failing descriptor: {c:campingListForm$controller$submitForm}
for the second function SubmitFormm (with two"m" at the end) i have as error :
Action failed: c:campingListForm$controller$submitFormm [component.getItem is not a function] Failing descriptor: {c:campingListForm$controller$submitFormm}
There is my campingListFormHelper.js
({ addItem: function(component, newItem) { var addItem = component.getItem("addItem"); addItem.setParams({ "item": item }); addItem.fire(); component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c', 'Name': '', 'Quantity__c': 0, 'Price__c': 0, 'Packed__c': false }); }, validateItemForm: function(component) { // Simplistic error checking var validItem = true; // Name must not be blank var nameField = component.find("itemname"); var itemname = nameField.get("v.value"); if ($A.util.isEmpty(itemname)){ validItem = false; nameField.set("v.errors", [{message:"Item name can't be blank."}]); } else { nameField.set("v.errors", null); } // Quantity must not be blank var quantityField = component.find("quantity"); var quantity = nameField.get("v.value"); if ($A.util.isEmpty(quantity)){ validItem = false; quantityField.set("v.errors", [{message:"Quantity can't be blank."}]); } else { quantityField.set("v.errors", null); } // Price must not be blank var priceField = component.find("price"); var price = priceField.get("v.value"); if ($A.util.isEmpty(price)){ validItem = false; priceField.set("v.errors", [{message:"Price can't be blank."}]); } else { quantityField.set("v.errors", null); } return (validItem); } })