This post explains how to make text field read only in LWC and AURA salesforce. To make the field read only in lightning there are two ways :
- readonly="true"
- disabled = "true"
readOnly.html(LWC):
<template>
<div style="padding-left:100px; width:300px;">
<lightning-input type="text" label="This is read only field" value="Read only field" readonly/>
</div>
<div style="padding-left:100px; width:300px;">
<lightning-input type="text" label="This is read only field" value="Read only field" disabled="true"/>
</div>
</template>
readOnly.cmp(AURA):
<aura:component >
<div style="padding-left:100px; width:300px;">
<lightning:input type="text" readonly="true" value="Read only field" label="This is read only field" />
</div>
<div style="padding-left:100px; width:300px;">
<lightning:input type="text" disabled="true" value="Read only field" label="This is read only field" />
</div>
</aura:component>
No comments:
Post a Comment