Skip to main content
2 of 2
add further explanation
David Manners
  • 27.3k
  • 9
  • 76
  • 220

The problem is that you cannot use depends on widget items that are of type chooser :(

In the file js/mage/adminhtml/form.js it processes the changes on widgets in the function trackChange. Here is loads the hidden field that is used to store the value of the item as a reference and the using up it works up the dom to find the td that is should show or hide.

The problem with the chooser items is that there is no hidden input field that matches the id format that magento is looking for.

You will see the JS error Uncaught TypeError: Cannot read property 'up' of null.

To get part of the depends working you can look into how the html of the chooser is built in the file Mage_Widget_Block_Adminhtml_Widget_Chooser. By simply adding a hidden field with the id $element->getId() to the returned string of the function _toHtml the field itself with hide/show but the button for choosing will not as this is part of a different row in the table. Here you would have to update the javascript to deal with the structure. Luckly the $chooserId that is used to build the button appears to be derived from the element id and so this should be fairly simply to find via javascript.

David Manners
  • 27.3k
  • 9
  • 76
  • 220