2

How to use linking properties of UI components to trigger 'disabled' on input based on checkbox 'value'?

From documentation, there are few ways to use export / import / links / listens to trigger disabled value of one input based on the value of another. I've tried few combinations but only thing I achieved is disabling field. How do I link monday_status value to trigger monday_open disabled flag?

XML:

<field name="monday_status">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 ...
 <item name="dataScope" xsi:type="string">monday_status</item>
 <item name="default" xsi:type="number">1</item>
 <item name="links" xsi:type="array">
 <item name="disabled" xsi:type="string">value</item>
 </item>
 </item>
 </argument>
</field>
<field name="monday_open">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 ...
 <item name="formElement" xsi:type="string">select</item>
 <item name="dataScope" xsi:type="string">monday_open</item>
 <item name="links" xsi:type="array">
 <item name="disabled" xsi:type="string">disabled</item>
 </item>
 </item>
 </argument>
</field>

I've removed redundant code.

LucScu
2,36230 silver badges40 bronze badges
asked Jul 13, 2017 at 9:00

1 Answer 1

0

If the monday_status is the checkbox, you could link its check status to monday_open enable/disable status with this code:

 <field name="monday_status">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
<item name="formElement" xsi:type="string">checkbox</item>
 <item name="dataScope" xsi:type="string">monday_status</item>
 <item name="default" xsi:type="number">1</item>
 <!-- here the correct linking property -->
 <item name="exports" xsi:type="array">
 <item name="checked" xsi:type="string">${$.parentName}.monday_open:disabled</item>
 </item>
 </item>
 </argument>
 </field>
<field name="monday_open">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 ...
 <item name="formElement" xsi:type="string">select</item>
 <item name="dataScope" xsi:type="string">monday_open</item>
 <!-- remove your linking property from this components -->
 </item>
 </argument>
</field>
Zahirabbas
2,0933 gold badges25 silver badges48 bronze badges
answered Jan 29, 2021 at 11:05

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.