【发布时间】:2014-01-23 11:21:54
【问题描述】:
在 Magento 的管理区域中,我正在尝试创建一个依赖字段。依赖字段是一个仅根据其值变为可用/启用的字段,例如,带有“是”或“否”值的下拉列表。这是 Magento 的内置功能,您可以从 this blog post 看到。
但是,上面的博客文章(以及我发现的其他文章)假设字段被添加到 system.xml 或使用下面概述的方法 Vikram 但我想在定义我的属性时在我的模块安装脚本中添加我的依赖项,例如:
$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)
)
);
有人知道这是否可能吗?
【问题讨论】:
标签: magento