0

I am creating the form using:

<lightning:recordForm
    aura:id="data-export-form"
    objectApiName="{!v.sObjectName}"
    fields="Account__c"
    columns="1"
    mode="edit"
    onsubmit="{!c.export}" />

So i can get the form from the JS controller using:

component.find('data-export-form')

But I can't figure out how to get the value of the one lookup field that is created by this form, Account__c (defined in the fields param). Since this form is creating the input it doesn't have an aura:id, and I can't use vanilla javascript functions like querySelector in lightning.

Thanks in advance.

0

1 Answer 1

1

You can iterate over individual fields of lightning:recordForm by using fields object returned by event onsubmit. Something like below:

    export : function(component, event, helper) {
    var eventFields = event.getParam("fields");
    var field = 'Account__c';
    if (eventFields.hasOwnProperty(field)) {
        if ( !eventFields.Account__c) { 
            event.preventDefault();           
            'Logic if field value is blank'
        }
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .