1

我想在我的产品编辑页面下的管理表单中添加一个价格字段,但我无法在我的字段集中添加“价格”类型。

$fieldset->addField($attribute->getAttributeCode(), 'price', array(
             'label'     => Mage::helper('mymod')->__($attribute->getFrontendLabel()),
             'class'     => $attribute->getIsRequired()?'required-entry':'',
             'required'  => $attribute->getIsRequired()?true:false,
             'name'      => $attribute->getAttributeCode(),
             'note'     => Mage::helper('mymod')->__($attribute->getNote()),
        ));

它给出了以下错误。

Fatal error: Class 'Varien_Data_Form_Element_Price' not found in .. /lib/Varien/Data/Form/Abstract.php on line 144

PS。我正在挖掘代码

Mage_Adminhtml_Block_Widget_Form

在哪里起作用

_setFieldset

它可以使用价格作为字段类型。

编辑@ 11/6:

从第一行开始深入研究 _setFieldset()

$this->_addElementTypes($fieldset);

将调用一个可实现的函数

function _getAdditionalElementTypes()

添加不在给定列表中的其他数据类型(例如价格,画廊..)。

4

1 回答 1

4

我认为您只需要这样做,text因为这些是可用的选项:

Button
Checkbox
Checkboxes
Collection
Column
Date
Editor
Fieldset
File
Gallery
Hidden
Image
Imagefile
Label
Link
Multiline
Multiselect
Note
Obscure
Password
Radio
Radios
Reset
Select
Submit
Text
Textarea
Time
于 2012-06-11T08:44:13.127 回答