0

Is it possible to disable a toogle if is checked ?

<lightning:input type="toggle"  name="togglevalue" checked="false" messageToggleActive="ok" messageToggleInactive="not ok"  disabled="{!if checked}" />

3 Answers 3

3

Answer is yes. You can do it. Firstly you need to declare one variable in component and need to assign in lightning input value and same can be used into disable attribute.

<aura:attribute name="toggleFieldValue" type="boolean" default="false" />

<lightning:input type="toggle"  name="togglevalue" checked="{!v.toggleFieldValue}" messageToggleActive="ok" messageToggleInactive="not ok"  disabled="{!v.toggleFieldValue}" />
1

Yes its possible, you just have to use your boolean field on the object.

<lightning:input type="toggle"  name="togglevalue" checked="false" messageToggleActive="ok" messageToggleInactive="not ok"  disabled="{!v.yourObject.yourObjBoolean}" />

Or the boolean attribute value populated.

<aura:attribute name="yourBoolean" type="boolean" default="false" />
<lightning:input type="toggle"  name="togglevalue" checked="false" messageToggleActive="ok" messageToggleInactive="not ok"  disabled="{!v.yourBoolean}" />

Providing a little more code might help us help you more. More context helps get better answers! :)

1
<aura:attribute name="togglecheck" type="Boolean"/>    
<lightning:input type="toggle"  name="togglevalue" checked="{!v.togglecheck}" messageToggleActive="ok" messageToggleInactive="not ok"  disabled="{!v.togglecheck}" />

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .