LWC create Record RecordEditForm
Use the lightning-record-edit-form component to create a
form that's used to add a Salesforce record or update fields in an existing
record. The component displays fields with their labels and the current values,
and enables you to edit their values.
http://simpluslabs.com/how-to-create-update-delete-and-fetch-records-in-lightning-web-component/
<template>
createAccountRecord<lightning-card title="Create Account" icon-name="custom:custom57"></lightning-card>
<div class="slds-grid slds-wrap slds-p-around_small">
<!-- Create a record with Lightning Data Service -->
<div class="slds-col">
<lightning-record-form object-api-name={accountObject} fields={myFields} onsuccess={handleSuccess} onsubmit={handleSubmit}> mode="edit">
</lightning-record-form>
</div>
</div>
</template>
createAccountRecord.js
import { LightningElement } from 'lwc';
import
accountObject from '@salesforce/schema/Account';
import
nameField from '@salesforce/schema/Account.Name';
import
websiteField from '@salesforce/schema/Account.Website';
import
industryField from '@salesforce/schema/Account.Industry';
export default
class CreateAccountRecord extends LightningElement {
// Code
for create the Account Record
accountObject =
accountObject;
myFields =
[nameField, websiteField, industryField];
handleSubmit(){
}
handleSuccess()
{
}
}
<createAccountRecord.js-meta.xml<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
</LightningComponentBundle>
Comments
Post a Comment