In the administration area of Magento I am trying to create a dependant field. A dependant field is one that only becomes available/enabled depending on the value of, let's say, a drop down with 'Yes' or 'No' values. This is a built in feature of Magento as you can see from this blog post.
However the above blog post (and others I have found) assumes the fields are getting added in system.xml or using the method Vikram outlined below but I would like to add my dependency in my modules install script when I define my attributes, for example:
$installer->addAttribute(
'catalog_category',
'show_dependant',
array(
'label' => 'Show dependant?',
'group' => 'My Group',
'type' => 'int',
'input' => 'select',
'source' => 'eav/entity_attribute_source_boolean',
'required' => false,
'visible' => true,
'default' => '0',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
)
);
$installer->addAttribute(
'catalog_category',
'my_attribute_name',
array(
'label' => 'A New Attribute',
'group' => 'My Group', //will be created if necessary
'type' => 'int',
'class' => 'validate-number',
'required' => false,
// Would be something like this maybe?
'depends' => array('show_dependant', 1)
)
);
Anyone know if this is even possible?