我想在客户端的Magento的后端创建一个只读字段。创建要知道的字段(通过模块)如下所示:
$installer->addAttribute("customer", "attrcode", array(
"type" => "varchar",
"backend" => "",
"label" => "label",
"input" => "text",
"source" => "",
"visible" => true,
"required" => false,
"default" => "",
"frontend" => "",
"unique" => false,
));这样它就产生了场,但他不仅仅是在读...
谢谢
发布于 2013-05-14 07:45:27
一种可能的解决方案是使用javascript禁用页面加载时的按钮。
创建一个js文件并将其上传到管理皮肤/js目录(disable_button.js)
添加
document.observe('dom:loaded', function(){
$("target_input_id").disabled=true;
});然后添加或更新您的local.xml以包含js文件
<?xml version="1.0"?>
<layout version="0.1.0">
<adminhtml_customer_edit>
<reference name="head">
<action method="addItem"><type>skin_js</type><script>js/disable_button.js</script></action>
</reference>
</adminhtml_customer_edit>
</layout>发布于 2013-05-14 07:34:09
我认为使用addAttribute()是不可能的,_prepareValues($attr)方法只允许存储在$data中的特定值。
查看@ app/code/core/Mage/Eav/Model/Entity/Setup.php
public function addAttribute($entityTypeId, $code, array $attr)
{
$entityTypeId = $this->getEntityTypeId($entityTypeId);
$data = array_merge(
array(
'entity_type_id' => $entityTypeId,
'attribute_code' => $code
),
$this->_prepareValues($attr);
);
.....
if ($attributeId) {
$this->updateAttribute($entityTypeId, $attributeId, $data, null, $sortOrder);
} else {
$this->_insertAttribute($data);
}
.......
}
protected function _prepareValues($attr)
{
$data = array(
'backend_model' => $this->_getValue($attr, 'backend'),
'backend_type' => $this->_getValue($attr, 'type', 'varchar'),
'backend_table' => $this->_getValue($attr, 'table'),
'frontend_model' => $this->_getValue($attr, 'frontend'),
'frontend_input' => $this->_getValue($attr, 'input', 'text'),
'frontend_label' => $this->_getValue($attr, 'label'),
'frontend_class' => $this->_getValue($attr, 'frontend_class'),
'source_model' => $this->_getValue($attr, 'source'),
'is_required' => $this->_getValue($attr, 'required', 1),
'is_user_defined' => $this->_getValue($attr, 'user_defined', 0),
'default_value' => $this->_getValue($attr, 'default'),
'is_unique' => $this->_getValue($attr, 'unique', 0),
'note' => $this->_getValue($attr, 'note'),
'is_global' => $this->_getValue($attr, 'global',
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL
),
);
return $data;
}发布于 2015-08-21 18:12:39
我已经开发了这样的扩展,为产品,类别和CMS页面工作。您只需定义一些规则并选择要显示为只读的属性。

https://stackoverflow.com/questions/16529412
复制相似问题