Working and usage of lightning:recordEditForm

A lightning:recordEditForm component is a wrapper component that accepts a record ID, and it displays one or more fields and labels associated with that record.  It use the lightning:inputField component inside to create editable fields. And it also use the lightning:outputField component and other display components such as lightning:formattedName  to display read-only information in your form.

lightning:recordEditForm 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.

lightning:recordEditForm and lightning:inputField support the following features:
1. Display a record edit layout for editing a specified record.
2. Display a record create layout for creating a new record.

You must include lightning:messages to support error handling and displaying of error messages. Additionally, this component provides basic input validation. For example, entering an invalid email format for the Email field results in an error message when you try to submit the change.

Note: This component doesn’t support all Salesforce standard objects. For example, the Event and Task objects are not supported.

Consider the following code for editing a record:

To enable record editing, pass in the ID of the record and the corresponding object API name to be edited. Specify the fields you want to include in the record edit layout using lightning:inputField.

Output:

 

Creating a record:

To enable record creation, pass in the object API name for the record to be created. Specify the fields you want to include in the record create layout.

Consider the  following code:
Output:

Try demo:

 

Refer to link to know more about Difference b/w lightning:recordEditform, force:recordData and lightning:recordForm.

Write a Response

Your email address will not be published.


Find Out How We Can Help

If you're ready to find out more about how SimplusLabs can help energize your workers, your customers, and your business with a different experience, let's talk.