You need to sign in to do that
Don't have an account?
Rama_SFDC
How to pass field API names in LWC from design property
Hi All ,
Please help me to fix below issue ,
I'm creating a reusable component in lWC with using recordeditfrom and i'm passing field api name and object from design property . it is working fine with object api name when passing from desing property but when i passing field api name is not working , please find below my code and where i did mistake ?
Metadata.xml :
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="MyComponent">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordPage">
<property name="Mode" type="String" label="Mode" datasource="Read Only, View ,Edit"/>
<property name="objectName" type="String" label="objectName" />
<property name="fieldnames" type="String" label="fieldnames" />
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
HTML :
<template>
<lightning-record-edit-form object-api-name={objectName}>
<lightning-messages>
</lightning-messages>
<template for:each={fieldnames} for:item="item" >
<div key={item} >
<lightning-input-field field-name= {item}> </lightning-input-field>
</div>
</template>
<lightning-button class="slds-m-top_small" type="submit" label="Create new" >
</lightning-button>
</lightning-record-edit-form>
</template>
js controller :
import { LightningElement, api } from 'lwc';
export default class MyComponent extends LightningElement {
@api recordId;
@api objectName ;
@api fieldnames ;
}
Thanks in Advance
Please help me to fix below issue ,
I'm creating a reusable component in lWC with using recordeditfrom and i'm passing field api name and object from design property . it is working fine with object api name when passing from desing property but when i passing field api name is not working , please find below my code and where i did mistake ?
Metadata.xml :
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="MyComponent">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordPage">
<property name="Mode" type="String" label="Mode" datasource="Read Only, View ,Edit"/>
<property name="objectName" type="String" label="objectName" />
<property name="fieldnames" type="String" label="fieldnames" />
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
HTML :
<template>
<lightning-record-edit-form object-api-name={objectName}>
<lightning-messages>
</lightning-messages>
<template for:each={fieldnames} for:item="item" >
<div key={item} >
<lightning-input-field field-name= {item}> </lightning-input-field>
</div>
</template>
<lightning-button class="slds-m-top_small" type="submit" label="Create new" >
</lightning-button>
</lightning-record-edit-form>
</template>
js controller :
import { LightningElement, api } from 'lwc';
export default class MyComponent extends LightningElement {
@api recordId;
@api objectName ;
@api fieldnames ;
}
Thanks in Advance