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
Saket Ranjan 3Saket Ranjan 3 

Aura component basics Trailhead connect component with event :: i have done the task using <ui: input ...> but when using <lightening: ...>my error ::Action failed: c:campingListForm$controller$submitForm [Cannot read property 'config' of undefined]

User-added imagewhen i am using <ui> tags then its working but the moment i move to lightening tag its throwing above error,. i am new to the salesforce development.



campingListForm.cmp::

<aura:component >
    
    <aura:attribute name="newItem" type="Camping_Item__c"
                    default="{ 'sobjectType': 'Camping_Item__c',
                             'Name': '',
                             'Quantity__c': 0,
                             'Price__c': 0,
                             'Packed__c': false }"/>
    <aura:registerEvent name="addItem" type="c:addItemEvent"/>
    <!-- CREATE NEW ITEM FORM -->
   <form >

      <div >
          <div >
               <lightning:input aura:id="itemname"
                                    value="{!v.newItem.Name}"
                                label="Name" 
                                required="true"/>
              <!--ui:inputText aura:id="itemname" label="Name"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Name}"
                  required="true"/-->


          </div>
     </div>

     <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputNumber aura:id="quantity" label="Quantity"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Quantities__c}"
                  required="true"/>

          </div>
      </div>

      <div class="slds-form-element">
          <div class="slds-form-element__control">
              <ui:inputCurrency aura:id="price" label="Price"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Price__c}"
                  />
          </div>
      </div>

      <div class="slds-form-element">
          <ui:inputCheckbox aura:id="packed" label="Packed?"
              class="slds-checkbox"
              labelClass="slds-form-element__label"
              value="{!v.newItem.Packed__c}"/>
      </div>

      <div class="slds-form-element">
          <ui:button label="Create Camping Item"
              class="slds-button slds-button--brand"
              press="{!c.submitForm}"/>
      </div>

    </form>
    <!-- / CREATE NEW ITEM FORM -->
</aura:component>

campingListFormController.js:

({
    
    submitForm : function(component, event, helper) {    
    if(helper.validateItemForm(component)){
          console.log("submitForm of campingListFormController");
        // Create the new item
        var newItem = component.get("v.newItem");
        helper.createItem(component, newItem);
    }
        
        }

})

campingListFormHelper.js ::

({
    
    
    createItem : function(component) {
        var newItem = component.get("v.newItem");
        var addEvent = component.getEvent("addItem");
        addEvent.setParams({"item" : newItem});
         console.log("createItem of campingListFormHelper");
        addEvent.fire();
        component.set("v.newItem",
                      { 'sobjectType': 'Camping_Item__c',
                       'Name': '',
                       'Packed__c': false,
                       'Price__c': 0,
                       'Quantity__c': 0});
    },
    
    
    validateItemForm: function(component) {
         
        // Simplistic error checking
        var validItem = true;
       console.log("validateItemForm of campingListFormHelper");
        // 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);
        
    }
})