</depends>
is not working in my below widget configuration inside widget.xml
. Can any one help me on this. I want to display values based on pre selected value.
<parameters>
<parameter name="available_options" xsi:type="select" visible="true">
<label translate="true">Choose Style Dropdown</label>
<description translate="true">Image getting displayed in various sizes.</description>
<options>
<option name="newsletter" value="newsletter">
<label translate="true">Email subscribe</label>
</option>
<option name="category_link" value="category_link">
<label translate="true">Link to a category</label>
</option>
<option name="product_page" value="product_page">
<label translate="true">Product detail page</label>
</option>
</options>
</parameter>
<parameter name="id_path_product" xsi:type="block" visible="true" sort_order="10">
<label translate="true">Link to a Specified Product</label>
<depends>
<parameter name="available_options" value="product_page" />
</depends>
<block class="Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser">
<data>
<item name="button" xsi:type="array">
<item name="open" xsi:type="string" translate="true">Select Product...</item>
</item>
</data>
</block>
</parameter>
</parameters>
Best Answer
The problem is that the JS that handles the show/hide functionality of dependency elements doesn't find anything in the case of
xsi:type="block"
fields.One way to get around this is to override the JS to add support for the product chooser parameter.
In a custom module, add these files:
{module_dir}/view/adminhtml/web/requirejs-config.js
and now we override the core JS with a JS file that has a few tweaks. copy the file from
{magento_dir}/lib/web/mage/adminhtml/form.js
to: {module_dir}/view/adminhtml/web/js/form.js and change thetrackChange
method (line 361) to the following:now the product chooser field will behave as expected.