For example:
You have two attribute of product: field_main and field_sub.
Your attribute field_sub is dependent on field_main attribute’s value.
Now, you need to add following code in your plugin:
In app/code/Vendor/Module/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="field_sub" xsi:type="array">
<item name="class" xsi:type="string">Vendor\Module\Ui\DataProvider\Product\Form\Modifier\FieldSub</item>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
</arguments>
</virtualType>
</config>
Now define your attribute’s data provider:
create file at path:
Vendor\Module\Ui\DataProvider\Product\Form\Modifier\FieldSub.php
<?php
namespace Vendor\Module\Ui\DataProvider\Product\Form\Modifier;
use Magento\Framework\Stdlib\ArrayManager;
class FieldSub extends \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier
{
/**
* @var ArrayManager
* @since 101.0.0
*/
protected $arrayManager;
public function __construct(
ArrayManager $arrayManager
) {
$this->arrayManager = $arrayManager;
}
public function modifyMeta(array $meta)
{
$meta = $this->customizeFieldSub($meta);
return $meta;
}
public function modifyData(array $data)
{
return $data;
}
protected function customizeFieldSub(array $meta)
{
$weightPath = $this->arrayManager->findPath('field_sub', $meta, null, 'children');
if ($weightPath) {
$meta = $this->arrayManager->merge(
$weightPath . static::META_CONFIG_PATH,
$meta,
[
'dataScope' => 'field_sub',
'validation' => [
'required-entry' => true,
'validate-zero-or-greater' => true
],
'additionalClasses' => 'admin__field-small',
'imports' => [
'disabled' => '!${$.provider}:' . self::DATA_SCOPE_PRODUCT
. '.field_main:value'
]
]
);
}
return $meta;
}
}
In di.xml we map the field’s data provider.
In fieldSub.php file, modifyMeta() calls to modify the attribute, in this function we added additional checks to our field, which are:
- data_scope: is the name of the field (field code)
- validation: validations which we want to apply on our filed.
- additionalClasses : if want to add additional class to our field.
- imports: in this we pass the attributes value, like: disabled,
product-id, or any other attribute to add in element.
After this flush the cache, and your field (field_sub) will be dependent on other field’s (field_main) value.

Reference: https://webkul.com/blog/depend-attribute-field-attributes-field-admin-form-magento2/
I hope this will help