Magento Admin Module – Part-3
来源:互联网 发布:php web 应用开发 编辑:程序博客网 时间:2024/05/21 06:54
这篇文章,将要介绍如何创建admin forms
前面的两篇文章,已经详细的介绍了admin grid,这篇文章我们将详细的介绍一下如何在后台创建表单
Forms在magento中可以划分为四个基础部分
1. FORM Container
2. FORM tag
3. FORM Tabs
4. Actual Form Fields
首先,把下面代码放入后台控制器中去,用来显示表单app/code/local/Demo/Simple/controllers/Adminhtml/BlogController.php
public function newAction(){ $this->loadLayout(); $this->_addContent( $this->getLayout()->createBlock('simple/adminhtml_blog_edit') ) ->_addLeft( $this->getLayout()->createBlock('simple/adminhtml_blog_edit_tabs') ); $this->renderLayout();}newAction方法中,我们添加了两个Block,一个是内容区域,一个是左边的选项卡区域,这个页面包含两部分,一部分是内容部分$this->_addContent添加的block和左边选项卡,由_addLeft()方法添加的Block
FORM Container
FORM Container(表单容器)表单容器是什么呢?就像它的名字,在最外层的DIV元素里包含了所有的表单元素和html,为了创建一个表单容器,你需要再app/code/local/Demo/Simple/Block/Adminhtml/Blog创建一个Edit.php文件,在这个文件里创建的类,需要继承
Mage_Adminhtml_Block_Widget_Form_Container
自Mage_Adminhtml_Block_Widget_Form_Container类,把下面代码加入到Edit.php文件中class Demo_Simple_Block_Adminhtml_Blog_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{ public function __construct() { parent::__construct(); $this->_objectId = 'id'; $this->_blockGroup = 'simple'; $this->_controller = 'adminhtml_blog'; $this->_updateButton('save', 'label', Mage::helper('simple')->__('Save')); $this->_updateButton('delete', 'label', Mage::helper('simple')->__('Delete')); // $this->removeButton('reset'); $this->_addButton('saveandcontinue', array( 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'), 'onclick' => 'saveAndContinueEdit()', 'class' => 'save', ), -100 ); } public function getHeaderText() { return Mage::helper('simple')->__('My Form Container'); }}
让我们来分析一下此文件中的相关代码
getHeaderText(): This function return’s the Text to display as the form header. You can see the form header in the screenshot attached - See more at: http://excellencemagentoblog.com/module-development-series-magento-admin-module-part3#sthash.TslLnlod.dpuf
getHeaderText(): 这个方法在表单的头部显示表单的标题admin forms
0 0
- Magento Admin Module – Part-3
- magento admin module -- part-1
- Magento Admin Module – Part2
- magento 第2炮 admin module
- magento admin chrome firefox
- Magento Admin 官方文档
- magento add admin account
- Locked Out from Magento admin?
- 忘记 magento admin密码怎么办?
- Tax module in Magento
- Demystifying Magento’s Layout XML – Part 1
- Digging Deeper Into Magento’s Layout XML – Part 2
- 初探magento的MVC架构(Create new module “HelloWorld” – in Magento)
- Magento Local Module 会覆盖 Community Module
- magento 获得 module,action,method
- Magento admin system config 写好后注意事项
- Magento admin order item update custom option
- Magento Admin Form表单元素大全
- 立体类族共有的抽象类
- Visual Assist X 10.8.2036的Crack破解补丁.2014.05.22 (General release.)
- 通过一个函数调换两个数
- 只要能救出他,纵然身死灵灭,我亦在所不惜!我意已决,无须多言!
- 三学生上课玩手机遭批 喊十几人围砍老师
- Magento Admin Module – Part-3
- java路径
- mysql添加管理员
- 端午有礼之免费wifi篇
- 深挖少爷气质男星现状 《花儿与少年》张翰向郑爽示爱
- C#调用C++的dll时,c++ dll函数接口中尽量不要用bool返回类型
- Parcelable的方法
- 数据结构——归并排序
- 老太收养黑人弃婴 14年后落户上海