我已经使用安装程序向新管理面板添加了一个复选框,但是我无法在添加值时将其添加或在保存后检查它。这是安装程序脚本:
$installer->addAttribute('catalog_product', 'feature_activated', array(
'group' => 'New Feature Settings',
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Feature activated',
'input' => 'checkbox',
'class' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'apply_to' => '',
'is_configurable' => true,
'used_in_product_listing' => true,
'sort_order' => 15
));
当管理面板呈现时,它会生成:
<input id="feature_activated" name="product[feature_activated]" value class="" type="checkbox">
如果我选中该框并保存,则不保存该值(可能是因为没有值),显然,下次加载页面时它不显示为已选中。我在找到这方面的文档方面遇到了很多麻烦。有什么想法吗?
答案 0 :(得分:1)
我认为magento没有checkbox属性。如果这不是您的问题,您可以使用是/否选择字段。
$installer->addAttribute('catalog_product', 'feature_activated', array(
'group' => 'New Feature Settings'
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Feature activated',
'input' => 'select',
'class' => '',
'source' => 'eav/entity_attribute_source_boolean',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => '0',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'apply_to' => '',
'is_configurable' => true,
'used_in_product_listing' => true,
'sort_order' => 15
));