cancel
Showing results for 
Search instead for 
Did you mean: 

Adminhtml form component field dependency

Adminhtml form component field dependency

How can I make a form fields visibility depending on another fields (selected) value?

 

For example when my form looks like this:

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">... stuff ....</argument>
<dataSource>..stuff...</dataSource>

<fieldset name="general">
<field name="base_field">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string">Base field</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">select</item>
<item name="options" xsi:type="object">Company\Module\Model\Config\Source\MySource</item>
</argument>
</field>
<field name="another_field">
<item name="depends" xsi:type="array">
<item name="base_field" xsi:type="number">1</item>
</item>
</field>
</fieldset>
</form>

 

Of course the item="depends" section does not work, so I am wondering if this is possible?