I have one yes/no select field in a widget.xml

If "yes" was selected then category select field should be visible.

But category select field always visible instead. That's wrong.

Here is my widget.xml:

<select_category_type translate="label description">
    <label>Select categories</label>
        <item0 translate="label">
        <item1 translate="label">

<selected_category translate="label">
    <label>Select categories</label>
            <button translate="open">
                 <open>Select Categories...</open>

1 Answer 1


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.

  • You're right. But is there some solutions to fix it?
    – Anthony
    Apr 28, 2014 at 12:03
  • @Anthony sadly I have not been able to find one yet. Apr 28, 2014 at 12:10
  • @Anthony I have updated with some more findings regarding when and where the html is built. Apr 29, 2014 at 6:49
  • This still happends in Magento 2 right? Jul 4, 2016 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.