0

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

0

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.