I'm using lightning:recordEditForm
and lightning:inputField
to update a record.
I need to validate the values before updation and I couldn't find any ways to get the values from lightning:recordEditForm
or lightning:inputField
.
How can I access the values from lightning:recordEditForm
and lightning:inputField
? Is it possible ?
If not why was it not allowed ?
Component:
<aura:component >
<aura:attribute name="fieldList" type="String[]" default="['Name','Email','Birthdate','Languages__c','MobilePhone']"/>
<lightning:recordEditForm recordId="003XXXXXXXXXXXXXXX" objectApiName="Contact" onsubmit="{!c.submitData}">
<lightning:messages />
<aura:iteration items="{!v.fieldList}" var="field">
<lightning:inputField aura:id="inputs" fieldName="{!field}" />
</aura:iteration>
<lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" />
</lightning:recordEditForm>
</aura:component>
Controller:
({
submitData : function(component, event, helper) {
var values = component.find('inputs');
console.log('values',values);
//Can't get the values.
}
})