Salesforce gives you three base components that all show a record form. 🧩
Last updated October 2026
They look almost identical in the docs. Pick the wrong one and you spend a week fighting it instead of shipping. Here is the lightning record form compared with the record edit form and the record view form, with code, limits and the moment it is time to build your own.
- lightning-record-form is the fastest to build and the least flexible
- lightning-record-edit-form gives full control over editable fields and supports default values
- lightning-record-view-form is read only with a layout you design
- All three use Lightning Data Service, so field level security and sharing are handled for you
- Several objects, heavy conditional logic or custom validation are the signal to build a custom form
What is lightning-record-form?
lightning-record-form is a base Lightning Web Component that displays, edits or creates a record with very little code. You give it an object, an optional record ID and either a layout type or a list of fields, and it builds the form, the buttons and the save logic for you.
Lightning record form vs edit form vs view form compared
| Capability | record-form | record-edit-form | record-view-form |
|---|---|---|---|
| Create records | ✓ Yes | ✓ Yes | ✕ No |
| Edit records | ✓ Yes | ✓ Yes | ✕ No |
| View records | ✓ Yes | ✕ No | ✓ Yes |
| Custom layout | ✕ No, columns only | ✓ Yes | ✓ Yes |
| Default or prefilled values | ✕ No | ✓ Yes | Not applicable |
| Custom submit logic | Limited | ✓ Yes, onsubmit | Not applicable |
| Best for | Quick standard forms | Custom create and edit | Custom read only views |
Building a form the base components cannot handle?
Book a call with our developers. We review your component or help you build a custom one.
When should you use lightning-record-form?
Use it when the form is standard and speed matters more than control. It supports three modes. Edit is the default when there is no record ID, view is the default when there is one, and readonly shows output fields without Save or Cancel buttons.
<template>
<lightning-record-form
record-id={recordId}
object-api-name="Account"
fields={fields}
columns="2"
mode="edit"
onsuccess={handleSuccess}>
</lightning-record-form>
</template>
// accountForm.js
import { LightningElement, api } from 'lwc';
import NAME from '@salesforce/schema/Account.Name';
import INDUSTRY from '@salesforce/schema/Account.Industry';
export default class AccountForm extends LightningElement {
@api recordId;
fields = [NAME, INDUSTRY];
handleSuccess() { /* show a toast or navigate */ }
}It stops working when you need to prefill values, control the layout beyond columns, or change what happens on submit in a meaningful way. It also does not support every standard object, so check the component reference for the one you use.
When should you use lightning-record-edit-form?
Use it when you need control over editable fields. You place each lightning-input-field yourself, set default values with the value attribute and intercept the submit event to adjust fields before saving.
<template>
<lightning-record-edit-form object-api-name="Case" onsubmit={handleSubmit}>
<lightning-messages></lightning-messages>
<lightning-input-field field-name="Subject"></lightning-input-field>
<lightning-input-field field-name="Priority" value="High"></lightning-input-field>
<lightning-button type="submit" label="Create case"></lightning-button>
</lightning-record-edit-form>
</template>
handleSubmit(event) {
event.preventDefault();
const fields = event.detail.fields;
fields.Origin = 'Web';
this.template.querySelector('lightning-record-edit-form').submit(fields);
}For a step by step walkthrough of changing values before save, see our guide on how to modify fields onsubmit in lightning record edit form.
When should you use lightning-record-view-form?
Use it when you need a read only view with your own layout, for example a summary card that mixes fields from one record with custom styling.
<template>
<lightning-record-view-form record-id={recordId} object-api-name="Opportunity">
<div class="slds-grid slds-gutters">
<div class="slds-col"><lightning-output-field field-name="Name"></lightning-output-field></div>
<div class="slds-col"><lightning-output-field field-name="Amount"></lightning-output-field></div>
<div class="slds-col"><lightning-output-field field-name="StageName"></lightning-output-field></div>
</div>
</lightning-record-view-form>
</template>When should you build a custom form instead?
Build your own when the form outgrows a single record. Typical signals are several objects in one form, complex conditional fields, related lists inside the form or validation that depends on data elsewhere. Use the Lightning Data Service wire adapters such as getRecord and updateRecord, or call Apex when you need transactions across objects.
If you need something more involved, our custom Lightning Web Component development team builds and reviews these regularly. For the adoption side, see our guide on LWC best practices that get components used, and for simple screens that need no code at all, our Flow guide covers screen flows.
What are the common mistakes?
Common questions
What is the difference between lightning-record-form and lightning-record-edit-form?
lightning-record-form builds the whole form for you from a layout or a field list, with built in buttons and modes. lightning-record-edit-form lets you place each input field yourself, set default values and change data before submit. Use the first for speed and the second for control.
Can lightning-record-form prefill values?
No. lightning-record-form does not support prepopulating field values when the form loads. If you need default values, use lightning-record-edit-form and set the value attribute on each lightning-input-field, or adjust the fields in the onsubmit handler before saving.
Does lightning-record-form respect field level security?
Yes. All three components use Lightning Data Service, which enforces field level security and sharing automatically. Users only see and edit the fields and records they have access to, so fields can disappear for some users without any error.
The right base component saves days, and the wrong one turns a simple form into a long week.
Need a custom LWC or a code review?
Book a call with our developers and bring the component that is fighting you.
If you are building something the base components cannot handle, book a call with our developers, and follow TrueSolv on LinkedIn for more practical LWC guides.
Tell us what you are building
Leave your details and a few words about the form or component. We will set up a call with one of our developers.