lightning:recordViewForm

Represents a record view that displays one or more fields, provided by lightning:outputField. This component requires API version 41.0 and later.

A lightning:recordViewForm component is a wrapper component that accepts a record ID and is used to display one or more fields and labels associated with that record using lightning:outputField. lightning:recordViewForm 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. This component also takes care of field-level security and sharing for you, so users see only the data they have access to.

To display the fields on a record, specify the fields using lightning:outputField.

<aura:component>
    <lightning:recordViewForm recordId="001XXXXXXXXXXXXXXX" objectApiName="My_Contact__c">
        <div>
            <lightning:outputField fieldName="Name" />
            <lightning:outputField fieldName="Email__c" />
        </div>
    </lightning:recordViewForm>
</aura:component>

For more information, see the lightning:outputField documentation.

Working with the View Layout

To create a multi-column layout for your record view, use the Grid utility classes in Lightning Design System. This example creates a two-column layout.

<aura:component>
    <lightning:recordViewForm recordId="001XXXXXXXXXXXXXXX" objectApiName="My_Contact__c">
    <div>
        <div>
            <!-- Your lightning:outputField components here -->
        </div>
        <div>
            <!-- More lightning:outputField components here -->
        </div>
    </div>
</lightning:recordViewForm>
</aura:component>

Attributes

Attribute Name Attribute Type Description Required?
body Component[] The body of the component. In markup, this is everything in the body of the tag.
class String A CSS class for the outer element, in addition to the component's base classes.
recordId String The ID of the record to be displayed. Yes
objectApiName String The API name of the object. Yes