How can I disable some fields if a checkbox is enabled in admin panel? I'm using UI Components and Field component.
I tried something like below but it's not working. 24 hours is a checkbox, if it's selected then from_date and to_date will be disable
<switcherConfig>
<rules>
<rule name="0">
<value>0</value>
<actions>
<action name="0">
<target>from_date</target>
<callback>disable</callback>
</action>
<action name="1">
<target>to_date</target>
<callback>disable</callback>
</action>
<action name="2">
<target>24_hours</target>
<callback>enable</callback>
</action>
</actions>
</rule>
</rules>
<enabled>true</enabled>
</switcherConfig>
asked Sep 3, 2021 at 14:28
1 Answer 1
You need to put the below code inside your "24_hours" field's setting.
<switcherConfig>
<rules>
<rule name="0">
<value>checked</value>
<actions>
<action name="0">
<target>from_date</target>
<callback>disable</callback>
</action>
<action name="1">
<target>to_date</target>
<callback>disable</callback>
</action>
</actions>
</rule>
</rules>
<enabled>true</enabled>
</switcherConfig>
answered Sep 6, 2021 at 7:11
default