Compare Base Components
Compare lightning-record*form
components to find the one that meets your use case.
These components provide a form layout. Field labels use values that are based on the default values in your org. The components handle record create, read, and update changes without requiring Apex code. They use Lightning Data Service to cache and share record updates across components.
lightning-record-edit-form
—Displays an editable form.lightning-record-view-form
—Displays a read-only form.lightning-record-form
—Supports edit, view, and read-only modes.
The components support the objects that User Interface API supports. See Supported Objects.
Feature | lightning-record-form | lightning-record-view-form | lightning-record-edit-form |
---|---|---|---|
Create Records | |||
Edit Records | |||
View Records | |||
Read-Only Mode | |||
Layout Types | |||
Multi Column Layout | |||
Custom Layout for Fields | |||
Custom Rendering of Record Data |
For most use cases, lightning-record-form
provides a great starting point. It combines and simplifies the functionality of lightning-record-view-form
and lightning-record-edit-form
. All three components support a multi column layout. For example, you can use <div class="slds-grid">
to create a column.
Specify either a layout type or the fields and the mode, and the component takes care of layout, validation, CRUD changes, and error handling. The lightning-record-form
component also switches from edit mode to view mode after changes are submitted successfully.
To improve performance, specify fields instead of a layout whenever possible. Specify a layout only when you want the administrator, not the component, to control the fields that are provisioned. The component must handle receiving every field that is assigned to the layout for the context user.
For more advanced use cases that require custom field layouts and custom rendering of record data, use lightning-record-view-form
and lightning-record-edit-form
.
If you need more customization than the base components allow, such as a custom user interface, see Build Custom UI to Create and Edit Records and Get Record Data.
See Also