I have a form that has multiple fields in it. I want the values of those fields when I click on the "Apply" button. I am creating a filter, so I need the values and the field name in a string so I can change my SOQL Query accordingly. I don't know how to go about the controller code. Do I use component.find or something else? I'm not sure. All the fields are created dynamically. So I can't use aura:id for them because that causes issues apparently. Is there a way to go about it?
Component Code:
<form aura:id ="filterForm">
<div class="slds-grid slds-gutters">
<div class="slds-col">
<aura:iteration items="{!v.filterList}" var="val">
<aura:if isTrue="{!val.type == 'PICKLIST'}">
{!val.pickListValue}
<lightning:select label="{!val.label}"><!--GET FROM CUSTOM LABEL-->
<option text="None" value="None"/>
<aura:iteration items="{!val.pickListValue}" var="val1">
<option text="{!val1.label}" value="{!val1.value}"/>
</aura:iteration>
</lightning:select>
<aura:set attribute="else">
<lightning:input label="{!val.label}" value = "{!v.collStrat}"/>
</aura:set>
</aura:if>
</aura:iteration>
<lightning:button class="slds-m-top_small" label="Cancel" />
<lightning:button onclick="{!c.handleSubmit}" class="slds-m-top_small" label="Apply" />
</div>
<div class="slds-col">
</div>
</div>
</form>
Controller Code:
handleSubmit: function(component, event, helper) {
component.set('v.filterOpen',false);
var mainForm = component.find("filterForm");
console.log(mainForm);
// var fields = event.getParam('fields');
},