2011-06-21 167 views

回答

3

在那裏你可以這樣做:

$setup->addAttribute('customer', 'custom_attribute', array(
    'type'  => 'text', 
    'label'  => 'Customer Custom Attribute', 
)); 

使用這些值來代替:

$setup->addAttribute('customer', 'custom_attribute', array(
    'type'  => 'int', 
    'label'  => 'Customer Custom Attribute', 
    'input'  => 'select', 
    'source' => 'eav/entity_attribute_source_boolean', 
)); 

typeint,因爲您通常會存儲所選值的索引,而不是值本身。 inputselect,所以管理員渲染器知道使用哪個控件。這裏顯示的source是一個常見示例,它提供了一個包含數字索引的「是」和「否」值的數組。

Magento代碼中有很多源代碼模型可以使用,您也可以創建自己的模型,查看任何現有模型以查看它是如何返回數組的。如果你自己創建,如果它使用文本索引而不是數字,那麼type將不得不更改回text

+0

感謝您的幫助。 – Plantex

相關問題