class My_Module_Adminhtml_My_Controller_Edit_Form extends Mage_Adminhtml_Block_Widget_Form_Container { public function __construct() { parent::__construct(); $this->_objectId = 'id'; $this->_blockGroup = 'my_module'; $this->_controller = 'adminhtml_my_controller'; //adding save and back buttons $this->_updateButton('save', 'label', $this->__('Save Item')); $this->_updateButton('back', 'onclick', 'setLocation(\''.$this->getUrl('*/*/').'\')'); } public function getHeaderText() { return Mage::helper('my_module')->__('Edit My Item'); } }
class Mage_Adminhtml_Block_Catalog_Product_Edit_Form extends Mage_Adminhtml_Block_Widget_Form_Container { protected function _construct() { $this->_blockGroup = 'catalog'; $this->_controller = 'product'; if ($this->_isAllowedAction('save')) { $this->_updateButton('save', 'label', Mage::helper('catalog')->__('Save Product')); $this->_addButton('saveandcontinue', array( 'label' => Mage::helper('catalog')->__('Save and Continue Edit'), 'onclick' => 'saveAndContinueEdit()', 'class' => 'save', ), -100); } parent::_construct(); } }In this example, a form container is created for the product edit page in the Magento admin panel. The `_blockGroup` and `_controller` properties are set, and the save and save and continue buttons are added to the container, but only if the current user is allowed to save changes.