+ Start a Discussion

How can I disable lightning input when edit of record which is already saved using lightning component?

Ashif KhanAshif Khan
Hi Mrunalini
Take a Boolean type attribute which you need to set True  if the record is saved. use in input as given below
<aura:attribute name="isSaved" type="Boolean" default="false" />

<lightning:input type="text" label="Name" name="Name"  disabled="{!isSaved}"/>
I hope this will help you
Any saved record is already populated and If I edit some field and again click on save button then that record should not be changed. So I want to disable that fields once a record is saved.
Means If any saved record is populated then that should be disabled for editing. So should I need to code for controller Js ??
Ashif KhanAshif Khan
Yes Mrunalini
You need to handle in JS controller as per your requirement.
Ajay K DubediAjay K Dubedi
Hi Mrunalini,

<aura:component controller='etc' implements="forceCommunity:searchInterface">
<aura:attribute name="visibileInputBox" type="Boolean" default="true" />

<aura:if isTrue="{! v.visibileInputBox }">
<lightning:input type="text" label="Name" name="Name"/>

Through this condition you can disabled the lightning input but you have to set 'visibileInputBox' attribute value false in controller of saved button.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Ajay Dubedi