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>

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>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.