1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<?php class Excellence_Form_Block_Adminhtml_Form_Edit extends Mage_Adminhtml_Block_Widget_Form_Container { public function __construct() { parent::__construct(); $this ->_objectId = 'id' ; $this ->_blockGroup = 'form' ; $this ->_controller = 'adminhtml_form' ; $this ->_updateButton( 'save' , 'label' , Mage::helper( 'form' )->__( 'Save' )); $this ->_updateButton( 'delete' , 'label' , Mage::helper( 'form' )->__( 'Delete' )); $this ->_addButton( 'saveandcontinue' , array ( 'label' => Mage::helper( 'adminhtml' )->__( 'Save And Continue Edit' ), 'onclick' => 'saveAndContinueEdit()' , 'class' => 'save' , ), -100); } public function getHeaderText() { return Mage::helper( 'form' )->__( 'My Form Container' ); } } |
Attached is a screenshot of the form container
Important things in the class are
- getHeaderText(): This function return’s the Text to display as the form header. You can see the form header in the screenshot attached .
- $this->_objectId: This variable is used in the form URL’s. This variable has the forms entity primary key, e.g the delete button URL would be module/controller/action/$this->_objectid/3
- $this->_blockGroup = ‘form’; and $this->_controller = ‘adminhtml_form’; There two variables are very important, these variables are used to find FORM tabs php file. i.e the path of the form tabs php should be {$this->_blockGroup . ‘/’ . $this->_controller . ‘_’ . $this->_mode . ‘_form’}. The value of $this->_mode by default is ‘edit’. So the path of the php file which contains the form tag in our case would be ‘form/adminhtml_form_edit_form’.
- $this->_updateButton() and $this->_addButton() are used to update/add buttons to the form container. These buttons are visible in the screenshot