lightning-record-view-form is standard component that lets users to create a form that displays fields data for a specific record of an object.
To specify read-only fields, use lightning-output-field components inside lightning-record-view-form. lightning-record-view-form requires a record ID to display the fields on the record. It doesn't require additional Apex controllers or Lightning Data Service to display record data.
You can display the record data with two ways:
We will discuss both in the ways in this article.
It is used in a situation where we don't want to customize the form layout. It will display fields as per standard layout. It accepts parameter recordId and objectApiName. You can also define the number of columns you want to display.
Here, I have created a component "recordViewDemo". Follow the below code to see the implementation.
Use record-id and object-api-name to pass the ID of the record and the corresponding object API name to be displayed. You can also specify other options like mode is view (read only mode),layout- (Full,Compact) is full that means it will display all the fields as per standard layout. You can also define no of columns to be