HI Sid, Can you try below below to hide lightning:input fileds.
Lightning Component Code:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
<aura:attribute name="acc" type="Account" default="{ 'sobjectType': 'Account' }"/>
<aura:attribute name="hide" type="string" default="true"/>
<form>
<lightning:input name="Name" label="Name" aura:id="accountName" value="{!v.acc.Name}" onchange="{!c.disableFields}"/>
<aura:if isTrue="{!v.hide}">
<lightning:input name="First Name" label="First Name" value="{!v.acc.firstName}"/>
<Lightning:input name="Last Name" label="Last Name" value="{!v.acc.lastName}"/>
</aura:if>
</form>
</aura:component>
js.cotroller Code
({
disableFields : function(component, event, helper) {
var val = component.find("accountName").get("v.value");
if(val != null){
component.set('v.hide' , "false");
}
}
})
Let me know if it didnt work for you.
4 respostas