IN CASE OF MANY FIELDS
import { LightningElement, wire, track, api } from 'lwc';
export default class TestCmp extends LightningElement {
@api recordId;
@track listOfFields = ['Name', 'Industry', 'Website'];
}
<lightning-record-edit-form record-id={recordId} object-api-name="Account">
<template for:each={listOfFields} for:item="fieldName">
<lightning-input-field key={fieldName} field-name={fieldName}></lightning-input-field>
</template>
</lightning-record-edit-form>
Record Edit Form Documentation
IN CASE OF SINGLE FIELD
JS File
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import ACCOUNT_OBJECT_NAME from '@salesforce/schema/Account.Name';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import { LightningElement, wire, track } from 'lwc';
export default class TestCmp extends LightningElement {
@track fieldLabel = '';
@track fieldValue;
@wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })
wiredOI({error, data}) {
if (data) {
this.fieldLabel = data.fields[ACCOUNT_OBJECT_NAME.fieldApiName].label
}
} else if (error) {
console.error('error');
}
}
HTML file
<lightning-input
label={fieldLabel}
value={fieldValue}>
</lightning-input>