You need to sign in to do that
Don't have an account?
kumarr
how to Pass values from component to controller
I have a lightning component which contains input fileds(checkbox and picklist). These fields are not related to any object.
How can i pass the field values from component to JS controller on click of submit button??
NOTE: I cannot make use of Component.find() or aura:attribute as the fields on the component are populated through aura:iteration.
Any help would be highly appreciated.
How can i pass the field values from component to JS controller on click of submit button??
NOTE: I cannot make use of Component.find() or aura:attribute as the fields on the component are populated through aura:iteration.
Any help would be highly appreciated.
Can you post your component your component here
Here is the component code
<aura:iteration items="{!v.formElement}" var="element" indexVar="indx">
<aura:if isTrue="{!element.formType=='Check Box'}">
<lightning:input aura:id="{!'field'+indx}" type="checkbox" name="{!'element-'+indx}" label="{!element.formLabel}" checked="{!element.formSelectedValue=='TRUE'}" onchange="{!c.onChnageCheck}"/>
</aura:if>
<aura:if isTrue="{!element.formType=='Pick List'}">
<lightning:select aura:id="{!'field'+indx}" name="{!'element-'+indx}" label="{!element.formLabel}" value=" {!element.formSelectedValue}" onchange="{!c.onChnageCheck}">
<aura:iteration items="{!element.formDefaultPicklistValue}" var="opt">
<option text="{!opt}" value="{!opt}"/>
</aura:iteration>
</lightning:select>
</aura:if>
<aura:if isTrue="{!element.formType=='Header'}">
<Br/> <p style="font-weight: bold; padding-bottom: 6px;">{!element.formLabel}</p>
</aura:if>
<aura:if isTrue="{!element.formType=='Text Area'}">
<aura:If isTrue="{!v.openChild}">
<lightning:textarea aura:id="{!'field'+indx}" name="{!'element-'+indx}" label="{!$Label.c.CL_OptionsLongText}" placeholder="{!$Label.c.CL_placeholder}" onchange="{!c.onChnageCheck}"/>
</aura:If>
</aura:if>
<aura:if isTrue="{!element.formType=='Backend'}">
<lightning:select aura:id="{!'field'+indx}" name="{!'element-'+indx}" label="{!$Label.c.CL_SelectAcontact}" value=" {!v.selectedContact}" onchange="{!c.onChnageCheck}">
<aura:iteration items="{!v.contacts}" var="contact">
<option text="{!contact.Name+' ('+contact.Email+')'}" value="{!contact.Id}"/>
</aura:iteration>
</lightning:select>
</aura:if>
</aura:iteration>
NOTE : I am not able to make use of aura:id since local Ids doesnot support expressions
You can pass parameters from components to apex
component: Apex class:
How will i get the value of the field??
Because here i am not able to make use of aura:attribute