{"id":2424,"date":"2026-10-23T13:00:00","date_gmt":"2026-10-23T07:30:00","guid":{"rendered":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/"},"modified":"2026-11-15T11:29:51","modified_gmt":"2026-11-15T05:59:51","slug":"lwc-record-form-edit-view","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/","title":{"rendered":"lightning-record-form, record-edit-form and record-view-form Explained"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>lightning-record-form<\/code> component gives you a working record form from a single tag. No Apex, no SOQL and no save logic. For most internal screens that is the whole job done, and it respects field level security automatically.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This post builds on <a href=\"https:\/\/swapnilzambare.com\/blog\/lightning-base-components-overview\/\">Lightning Base Components<\/a> and <a href=\"https:\/\/swapnilzambare.com\/blog\/lightning-data-service-lwc\/\">Lightning Data Service<\/a>. We will build course screens for Bright Path Tutors.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is lightning-record-form?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>lightning-record-form<\/code> component renders a record using the page layout, handles edit and save, and shows errors. It sits on top of the User Interface API, which is why it needs no Apex. There are three related components, each giving you more control and more markup.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of buying a suit. Record form is off the peg, record-edit-form is made to measure, and building fields by hand is sewing it yourself.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why lightning-record-form Matters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most forms are ordinary. Show some fields, let the user edit them, save and report errors. Writing that by hand means Apex, a wrapper, error handling and field security checks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using <code>lightning-record-form<\/code> removes all of it. Because the UI API enforces sharing and field level security, you cannot accidentally expose a field the user should not see.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How lightning-record-form Works<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The component talks to the UI API, which handles reading, validation and writing.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-diagram-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-diagram-1-1024x640.png\" alt=\"lightning-record-form diagram showing the save path through the UI API\" class=\"wp-image-2422\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-diagram-1-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-diagram-1-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-diagram-1-768x480.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">How a record form saves through the UI API.<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">The One Tag Version<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;\n    &lt;lightning-record-form\n        record-id={recordId}\n        object-api-name=\"Course__c\"\n        layout-type=\"Full\"\n        mode=\"view\"&gt;\n    &lt;\/lightning-record-form&gt;\n&lt;\/template&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That is a complete, working record page. Set <code>mode<\/code> to <code>edit<\/code> for an editable form, or <code>readonly<\/code> to remove the edit pencil.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Choosing Fields Instead of a Layout<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;lightning-record-form\n    record-id={recordId}\n    object-api-name=\"Course__c\"\n    fields={fields}\n    columns=\"2\"\n    mode=\"edit\"\n    onsuccess={handleSuccess}&gt;\n&lt;\/lightning-record-form&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>import NAME from '@salesforce\/schema\/Course__c.Name';\nimport FEE from '@salesforce\/schema\/Course__c.Fee__c';\nimport LEVEL from '@salesforce\/schema\/Course__c.Level__c';\n\nexport default class CourseForm extends LightningElement {\n    fields = [NAME, FEE, LEVEL];\n\n    handleSuccess(event) {\n        console.log('Saved record ' + event.detail.id);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Importing fields from <code>@salesforce\/schema<\/code> gives you a compile time reference. If an admin deletes the field, the deployment fails instead of the page breaking silently.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Creating a New Record with lightning-record-form<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Leave out <code>record-id<\/code> and the form creates a record instead of editing one.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;lightning-record-form\n    object-api-name=\"Course__c\"\n    fields={fields}\n    onsuccess={handleCreated}&gt;\n&lt;\/lightning-record-form&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The same markup therefore serves both a create screen and an edit screen. So one component can be dropped on a record page and on a standalone tab, and it does the right thing in each place.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Taking Control with record-edit-form<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When you need a custom layout, move to <code>lightning-record-edit-form<\/code> and place each field yourself.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;lightning-record-edit-form\n    record-id={recordId}\n    object-api-name=\"Course__c\"\n    onsuccess={handleSuccess}\n    onerror={handleError}&gt;\n\n    &lt;lightning-messages&gt;&lt;\/lightning-messages&gt;\n\n    &lt;lightning-layout multiple-rows=\"true\"&gt;\n        &lt;lightning-layout-item size=\"12\" medium-device-size=\"6\" padding=\"around-small\"&gt;\n            &lt;lightning-input-field field-name=\"Name\"&gt;&lt;\/lightning-input-field&gt;\n        &lt;\/lightning-layout-item&gt;\n        &lt;lightning-layout-item size=\"12\" medium-device-size=\"6\" padding=\"around-small\"&gt;\n            &lt;lightning-input-field field-name=\"Fee__c\"&gt;&lt;\/lightning-input-field&gt;\n        &lt;\/lightning-layout-item&gt;\n    &lt;\/lightning-layout&gt;\n\n    &lt;lightning-button\n        type=\"submit\"\n        variant=\"brand\"\n        label=\"Save course\"&gt;\n    &lt;\/lightning-button&gt;\n&lt;\/lightning-record-edit-form&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>lightning-messages<\/code> displays server errors. Without it, a validation rule failure shows nothing to the user.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Read Only Display with record-view-form<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;lightning-record-view-form record-id={recordId} object-api-name=\"Course__c\"&gt;\n    &lt;lightning-output-field field-name=\"Name\"&gt;&lt;\/lightning-output-field&gt;\n    &lt;lightning-output-field field-name=\"Fee__c\"&gt;&lt;\/lightning-output-field&gt;\n&lt;\/lightning-record-view-form&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This version never saves, so it suits summary panels and printable views. Because the UI API still supplies labels and formatting, a currency field shows its symbol and a date respects the user locale. You also keep field level security without writing a single check.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Attribute Reference<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This table lists the attributes you set most often.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Attribute<\/th><th>Purpose<\/th><\/tr><\/thead><tbody><tr><td>record-id<\/td><td>The record to load, omit to create<\/td><\/tr><tr><td>object-api-name<\/td><td>Which object the form is for<\/td><\/tr><tr><td>layout-type<\/td><td>Full or Compact, from the page layout<\/td><\/tr><tr><td>fields<\/td><td>An explicit list instead of a layout<\/td><\/tr><tr><td>columns<\/td><td>How many columns to render<\/td><\/tr><tr><td>mode<\/td><td>view, edit or readonly<\/td><\/tr><tr><td>density<\/td><td>comfy or compact spacing<\/td><\/tr><tr><td>onsuccess<\/td><td>Fires after a successful save<\/td><\/tr><tr><td>onerror<\/td><td>Fires when the save fails<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">The Three Components Compared<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This table shows the trade-off between speed and control.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>record-form<\/th><th>record-edit-form<\/th><th>record-view-form<\/th><\/tr><\/thead><tbody><tr><td>Editing<\/td><td>Yes<\/td><td>Yes<\/td><td>No<\/td><\/tr><tr><td>Markup needed<\/td><td>One tag<\/td><td>Each field<\/td><td>Each field<\/td><\/tr><tr><td>Custom layout<\/td><td>No<\/td><td>Yes<\/td><td>Yes<\/td><\/tr><tr><td>Built in buttons<\/td><td>Yes<\/td><td>No<\/td><td>Not needed<\/td><\/tr><tr><td>Best for<\/td><td>Fast standard forms<\/td><td>Custom edit screens<\/td><td>Read only displays<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-diagram-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-diagram-2-1024x640.png\" alt=\"lightning-record-form compared with lightning-record-edit-form\" class=\"wp-image-2423\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-diagram-2-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-diagram-2-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-diagram-2-768x480.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">record-form compared with record-edit-form.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In short, start with record-form. Move to record-edit-form only when the layout or logic demands it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A Real lightning-record-form Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Bright Path wants a quick edit panel on the Course page. It should show four fields, save inline, and show a toast when it succeeds.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: The Template<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;\n    &lt;lightning-card title=\"Quick edit\"&gt;\n        &lt;div class=\"slds-var-m-around_medium\"&gt;\n            &lt;lightning-record-form\n                record-id={recordId}\n                object-api-name=\"Course__c\"\n                fields={fields}\n                columns=\"2\"\n                mode=\"edit\"\n                onsuccess={handleSuccess}\n                onerror={handleError}&gt;\n            &lt;\/lightning-record-form&gt;\n        &lt;\/div&gt;\n    &lt;\/lightning-card&gt;\n&lt;\/template&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: The JavaScript<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>import { LightningElement, api } from 'lwc';\nimport { ShowToastEvent } from 'lightning\/platformShowToastEvent';\nimport NAME from '@salesforce\/schema\/Course__c.Name';\nimport FEE from '@salesforce\/schema\/Course__c.Fee__c';\nimport LEVEL from '@salesforce\/schema\/Course__c.Level__c';\nimport START from '@salesforce\/schema\/Course__c.Start_Date__c';\n\nexport default class CourseQuickEdit extends LightningElement {\n    @api recordId;\n    fields = [NAME, FEE, LEVEL, START];\n\n    handleSuccess() {\n        this.dispatchEvent(new ShowToastEvent({\n            title: 'Saved',\n            message: 'Course updated',\n            variant: 'success'\n        }));\n    }\n\n    handleError(event) {\n        this.dispatchEvent(new ShowToastEvent({\n            title: 'Could not save',\n            message: event.detail.message,\n            variant: 'error'\n        }));\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>@api recordId<\/code> decorator is what lets App Builder pass the current record into your component.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Expose It<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;targets&gt;\n    &lt;target&gt;lightning__RecordPage&lt;\/target&gt;\n&lt;\/targets&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Adding that to the meta XML lets an admin drag the component onto the Course record page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These are the events you can handle.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Event<\/th><th>Fires when<\/th><\/tr><\/thead><tbody><tr><td>onsuccess<\/td><td>The record saved, detail holds the id<\/td><\/tr><tr><td>onerror<\/td><td>The save failed, detail holds the message<\/td><\/tr><tr><td>onload<\/td><td>Record data finished loading<\/td><\/tr><tr><td>onsubmit<\/td><td>Before the save, lets you change fields<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with lightning-record-form<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Forgetting lightning-messages, so validation errors show nothing.<\/li>\n\n<li>Expecting onsubmit changes to work without calling preventDefault first.<\/li>\n\n<li>Using record-form when the design needs a custom layout.<\/li>\n\n<li>Hard coding field names as strings instead of importing from schema.<\/li>\n\n<li>Assuming it works for every object, when some are not UI API supported.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for lightning-record-form<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Import field references from @salesforce\/schema, never plain strings.<\/li>\n\n<li>Use layout-type Full so admins control the fields.<\/li>\n\n<li>Add lightning-messages to every record-edit-form.<\/li>\n\n<li>Show a toast on success so the user knows it saved.<\/li>\n\n<li>Check UI API support for the object before you build.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Build a component that creates a new Course record with three fields and shows a toast on success. Hint: leave record-id out of the tag.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Most Asked lightning-record-form Interview Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These lightning-record-form questions come up in most LWC interviews.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Basic lightning-record-form Interview Questions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: What does lightning-record-form do?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The lightning-record-form component renders a record, handles edit and save, and needs no Apex because it uses the UI API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: What are the three form components?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">They are lightning-record-form, lightning-record-edit-form and lightning-record-view-form.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: What are the modes?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The lightning-record-form modes are view, edit and readonly. View shows an edit pencil, while readonly does not.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: How do you create a record instead of editing one?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Leave out the record-id attribute, and then the form switches to create mode.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: What does layout-type do?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It renders fields straight from the page layout, either Full or Compact.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6: Which event tells you the save worked?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">onsuccess, whose detail contains the new record id.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7: Do these components need Apex?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No. They go through the UI API, which handles reading and writing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8: How does the component know the current record?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Through an @api recordId property that App Builder populates.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Intermediate lightning-record-form Interview Questions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q9: Why import fields from @salesforce\/schema?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because it creates a real dependency, so deleting the field fails the deployment rather than breaking the page quietly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q10: What is lightning-messages for?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It renders server errors inside a record-edit-form. Without it, validation failures are invisible.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q11: How do you change a value before saving?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Handle onsubmit, call preventDefault, change the fields, then call submit on the form.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q12: Does the UI API respect field level security?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. Fields the user cannot see are simply not returned or rendered.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q13: When would you use record-view-form?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a read only display where you still want field labels, formatting and security handled for you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q14: What is the difference between record-form and record-edit-form?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Record-form gives a finished form in one tag. Record-edit-form gives you control over layout and buttons, at the cost of more markup.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q15: Can you use these in a Flow screen?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, if the component targets lightning__FlowScreen in its meta XML.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q16: What does density control?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The spacing of the form, either comfy or compact.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced lightning-record-form Interview Questions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q17: Scenario: a field must default based on another field. How?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Handle onsubmit, prevent the default, adjust the fields object and submit it yourself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q18: Which objects are not supported?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Objects outside UI API support, including some setup and metadata objects. So check the support list before designing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q19: How do you handle a record page and a create page in one component?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Pass record-id conditionally. When it is undefined the same markup creates a record instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q20: Scenario: the form saves but a related record must update too. What do you do?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Handle onsuccess and call an Apex method for the related work, or move the whole save into Apex with record-edit-form.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q21: Why might record-form be the wrong choice for a wizard?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because it saves on each step. A wizard usually needs the record created once at the end, so manage the data yourself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q22: How does caching work here?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Lightning Data Service caches the record, so other components showing it refresh automatically after a save.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q23: How do you test these components?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With Jest, mocking the UI API modules, plus manual testing of the save path against real validation rules.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q24: What is the performance advantage over Apex?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The record is cached and shared across components, so repeated views do not hit the server again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q25: Can lightning-record-form show related records?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No, it works on one record. So use a datatable or a related list component beside it for children.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q26: Does lightning-record-form fire triggers?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. The save is a normal DML operation, so triggers, flows and validation rules all run as usual.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q27: How do you make some fields read only?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use record-edit-form and swap those fields to lightning-output-field. Alternatively, control it with field level security.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q28: Scenario: the form shows fewer fields than expected. Why?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Field level security is hiding them for that user. Because the UI API enforces access, this is working as designed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q29: Is lightning-record-form suitable for an Experience Cloud site?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, and guest or portal access is still enforced. However, always test as the external user before launch.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/component-library\/bundle\/lightning-record-form\/documentation\" target=\"_blank\" rel=\"noopener noreferrer\">Component Reference: lightning-record-form<\/a><\/li>\n\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/platform\/lwc\/guide\/data-ui-api.html\" target=\"_blank\" rel=\"noopener noreferrer\">LWC Guide: Work with Records<\/a><\/li>\n\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.uiapi.meta\/uiapi\/ui_api_get_started.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Salesforce Developers: User Interface API<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>lightning-record-form builds a working form from one tag.<\/li>\n\n<li>record-edit-form adds layout control, record-view-form is read only.<\/li>\n\n<li>Import field references from @salesforce\/schema.<\/li>\n\n<li>Add lightning-messages so errors are visible.<\/li>\n\n<li>The UI API enforces sharing and field level security for you.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Next, we handle large tables with <a href=\"https:\/\/swapnilzambare.com\/blog\/lwc-datatable-advanced\/\">lightning-datatable advanced features<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The lightning-record-form component gives you a working record form from a single tag. No Apex, no SOQL and no save logic. For most internal&hellip;<\/p>\n","protected":false},"author":1,"featured_media":2421,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[245,8,96],"tags":[26,113],"swapz_series":[],"class_list":["post-2424","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lightning-web-components","category-salesforce","category-salesforce-developer","tag-intermediate","tag-lwc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>lightning-record-form and record-edit-form Guide<\/title>\n<meta name=\"description\" content=\"Learn lightning-record-form, record-edit-form and record-view-form in LWC, with modes, custom layouts, validation and the most asked interview questions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"lightning-record-form and record-edit-form Guide\" \/>\n<meta property=\"og:description\" content=\"Learn lightning-record-form, record-edit-form and record-view-form in LWC, with modes, custom layouts, validation and the most asked interview questions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil Zambare - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-23T07:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-15T05:59:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil Zambare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil Zambare\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/\"},\"author\":{\"name\":\"Swapnil Zambare\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/10b09224c8bcc562716e86789427592a\"},\"headline\":\"lightning-record-form, record-edit-form and record-view-form Explained\",\"datePublished\":\"2026-10-23T07:30:00+00:00\",\"dateModified\":\"2026-11-15T05:59:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/\"},\"wordCount\":1556,\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/lwc-record-form-edit-view-featured.png\",\"keywords\":[\"Intermediate\",\"LWC\"],\"articleSection\":[\"Lightning Web Components\",\"Salesforce\",\"Salesforce Developer\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/\",\"name\":\"lightning-record-form and record-edit-form Guide\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/lwc-record-form-edit-view-featured.png\",\"datePublished\":\"2026-10-23T07:30:00+00:00\",\"dateModified\":\"2026-11-15T05:59:51+00:00\",\"description\":\"Learn lightning-record-form, record-edit-form and record-view-form in LWC, with modes, custom layouts, validation and the most asked interview questions.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/#primaryimage\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/lwc-record-form-edit-view-featured.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/lwc-record-form-edit-view-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"lightning-record-form featured image: code editor card with record form markup\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lwc-record-form-edit-view\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"lightning-record-form, record-edit-form and record-view-form Explained\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"name\":\"Swapnil Zambare - Blog\",\"description\":\"Salesforce &amp; Tech Guides\",\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\",\"name\":\"Swapnil Zambare - Blog\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"width\":512,\"height\":512,\"caption\":\"Swapnil Zambare - Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/theSwapnilZambare\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/10b09224c8bcc562716e86789427592a\",\"name\":\"Swapnil Zambare\",\"sameAs\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\"],\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/author\\\/swapnil-zambare\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"lightning-record-form and record-edit-form Guide","description":"Learn lightning-record-form, record-edit-form and record-view-form in LWC, with modes, custom layouts, validation and the most asked interview questions.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/","og_locale":"en_US","og_type":"article","og_title":"lightning-record-form and record-edit-form Guide","og_description":"Learn lightning-record-form, record-edit-form and record-view-form in LWC, with modes, custom layouts, validation and the most asked interview questions.","og_url":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/","og_site_name":"Swapnil Zambare - Blog","article_published_time":"2026-10-23T07:30:00+00:00","article_modified_time":"2026-11-15T05:59:51+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-featured.png","type":"image\/png"}],"author":"Swapnil Zambare","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Swapnil Zambare","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/#article","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/"},"author":{"name":"Swapnil Zambare","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/10b09224c8bcc562716e86789427592a"},"headline":"lightning-record-form, record-edit-form and record-view-form Explained","datePublished":"2026-10-23T07:30:00+00:00","dateModified":"2026-11-15T05:59:51+00:00","mainEntityOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/"},"wordCount":1556,"publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-featured.png","keywords":["Intermediate","LWC"],"articleSection":["Lightning Web Components","Salesforce","Salesforce Developer"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/","url":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/","name":"lightning-record-form and record-edit-form Guide","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-featured.png","datePublished":"2026-10-23T07:30:00+00:00","dateModified":"2026-11-15T05:59:51+00:00","description":"Learn lightning-record-form, record-edit-form and record-view-form in LWC, with modes, custom layouts, validation and the most asked interview questions.","breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-featured.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lwc-record-form-edit-view-featured.png","width":2400,"height":1260,"caption":"lightning-record-form featured image: code editor card with record form markup"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/lwc-record-form-edit-view\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"lightning-record-form, record-edit-form and record-view-form Explained"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil Zambare - Blog","description":"Salesforce &amp; Tech Guides","publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/swapnilzambare.com\/blog\/#organization","name":"Swapnil Zambare - Blog","url":"https:\/\/swapnilzambare.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","width":512,"height":512,"caption":"Swapnil Zambare - Blog"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/theSwapnilZambare"]},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/10b09224c8bcc562716e86789427592a","name":"Swapnil Zambare","sameAs":["https:\/\/swapnilzambare.com\/blog"],"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/2424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=2424"}],"version-history":[{"count":1,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/2424\/revisions"}],"predecessor-version":[{"id":3197,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/2424\/revisions\/3197"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/2421"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=2424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=2424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=2424"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=2424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}