Linux Magento 为管理模块创建新的字段类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3677165/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Magento create new field type for admin module
提问by Castro Roy
in a custom module with admin pages, in the file
app\code\local\Namespace\Mymodulw\Block\Myblock\Edit\Tab\Form.php
you can add somthing like this
在带有管理页面的自定义模块中,在文件
app\code\local\Namespace\Mymodulw\Block\Myblock\Edit\Tab\Form.php 中,您可以添加这样的东西
$fieldset->addField('title', 'text', array(
'label' => Mage::helper('mymodule')->__('Title'),
'class' => 'required-entry',
'required' => true,
'name' => 'title',
));
this create an input of type text in the edit page, what i'm trying to do is create a new type, then i can make something like this
这会在编辑页面中创建一个文本类型的输入,我想要做的是创建一个新类型,然后我可以做这样的事情
$fieldset->addField('title', 'mytype', array(
'label' => Mage::helper('mymodule')->__('Title'),
'class' => 'required-entry',
'required' => true,
'name' => 'title',
));
can you see the diference?? thanks
你能看出区别吗??谢谢
采纳答案by Jonathan Day
The adminhtml field types extend Varien_Data_Form_Element_Abstract
and are located in \lib\Varien\Data\Form\Element
. So you would need to create a new file called Mytype.php
with a declaration of class Varien_Data_Form_Element_Mytype extends Varien_Data_Form_Element_Abstract
and then override the Abstract methods to function as you need.
adminhtml 字段类型扩展Varien_Data_Form_Element_Abstract
并位于\lib\Varien\Data\Form\Element
. 因此,您需要创建一个Mytype.php
使用 的声明调用的新文件class Varien_Data_Form_Element_Mytype extends Varien_Data_Form_Element_Abstract
,然后覆盖抽象方法以根据需要运行。
Check out the files in that directory for examples.
查看该目录中的文件以获取示例。
Cheers, JD
干杯,JD