0

I have a requirement where I need to submit a feedback I am having two fields: NAME, FEEDBACK I am using the record edit form in LWC and there are other fields for feedback which are lookup fields of the parent object(these fields were not mentioned in the record edit form) now my requirement is on clicking the submit feedback button, it need to submit values of lookup fields from background using onsubmit event in js function, as I am new to lightning web component , please help me how to set the values of feedback's look up field values.

thanks in advance

1 Answer 1

1

You can handle that the onsubmit event of the record-edit-form. HTML

<lightning-record-edit-form 
     record-id={recordId}
     object-api-name={objectApiName}
     onsubmit={handleSubmit}
     ...
>
     ...
</lightning-record-edit-form>

JS

handleSubmit(event){
   event.preventDefault();       // stop the form from submitting
   const fields = event.detail.fields;
   fields.Name = 'name';
   fields.Feedback__c = 'feedback';
   this.template.querySelector('lightning-record-edit-form').submit(fields);
}

See the document for more details

1
  • thanks for the solution
    – akhil
    Feb 17, 2021 at 12:11

You must log in to answer this question.

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