+ Start a Discussion
vamshi kothakapu 9vamshi kothakapu 9 

Aura component specialist step2. Not able to save BoatSearch .cmp, .jsand helper aswell

Having issue with formsubmit event I guess. Below error is showing up while saving BoatSearch.
Failed to save BoatSearch.cmp: A aura:handler that specifies an event="" attribute must handle an application event. Either change the aura:event to have type="APPLICATION" or alternately change the aura:handler to specify a name="" attribute.: Source.
<!--BoatSearch.cmp-->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
     <aura:handler name="formsubmit" event="c:formsubmit" action="{!c.onFormSubmit}" phase="capture"/>
       <aura:attribute name="eventMessage" type="String"/> 
    
   <lightning:card title="Find A Boat">
       <c:BoatSearchForm  />
    </lightning:card>
    <lightning:card title="Matching Boats">
       <c:BoatSearchResults aura:id="searchResults" />
    </lightning:card>
</aura:component>
<!--BoatSearchForm.cmp-->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" controller="fetchPicklistOptsController" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
     <aura:attribute name="options" type="map" default="{Id:'value'}"/> 
     <aura:attribute name="boatTypeId" type="string" /> 
     <aura:attribute name="showNewButton" type="Boolean" default="true"/> 
      <aura:attribute name="formData" type="object" default=""/> 
    <!--<aura:registerEvent name="passBoatId" type="c.BoatId_serachform_BoatSerchResult"/>-->
    
    <aura:registerEvent name="formsubmit" type="c:formsubmit"/>
       <lightning:layout horizontalAlign="center" class="slds-align_absolute-center">
          <lightning:layoutItem padding="around-small">
              <lightning:select aura:id="boattypePicklist" value="{!v.options.Id}" onchange="{!c.onChange}" label="Alltype" required="true">
                  <option value="">All Types</option>
                  <aura:iteration items="{!v.options}" var="opt" indexVar="key">
                      <option text="{!opt.value}" value="{!opt.key}" selected="{!opt.key==v.options.Id}" />
                  </aura:iteration>
              </lightning:select>
          </lightning:layoutItem>
          <lightning:layoutItem padding="around-small">
              <lightning:button label="Search" class="slds-button slds-button_brand"  variant="brand" onclick="{!c.onFormSubmit}" />
              <aura:if isTrue="{!v.showNewButton}">
                  <lightning:button label="New" class="slds-button slds-button_neutral" variant="Neutral" onclick="{!c.NewBoat}"/>
              </aura:if>
          </lightning:layoutItem>
       </lightning:layout>
</aura:component>

<!--formsubmit.evt-->
<aura:event type="APPLICATION" description="Event template" >
    <aura:attribute name="formData" type="object"/>
</aura:event>
Please help me.
vamshi kothakapu 9vamshi kothakapu 9
Tried changing Application to component but no success to save
Sachin HoodaSachin Hooda
Hi Vamshi,
The code is working fine at my end. Is this still giving errors?
If the formsubmit.evt event is a component event, use the following
<aura:handler name="formsubmit" event="formsubmit" action="{!c.handleSubmit}" />
Or instead, 
you can simply pass the attributes like:
<c:BoarSearchForm FormData="{!v.formData}"/>
Try making minimal use of events.
____
Regards,
Sachin
(:
Lomash RegmiLomash Regmi
1. Your event type should be component
<!--formsubmit.evt-->
<aura:event type="COMPONENT" description="Event template" >
    <aura:attribute name="formData" type="object"/>
</aura:event>

2. aura:handler should look like this
<aura:handler name="formSubmitHandler" event="c:FormSubmit" action="{!c.onFormSubmit}"/>