Override adminhtml form magento

This tutorial explain how to override admin form magento. The tutorial show how to extend magento extension admin form and add new form fields as shown below.

Also refer the tutorial explains how to tables upgrade script and create magento admin grids.

rewrite adminhtml form magento

File Structure

The below file structure shows extended magento extension.

rewrite adminhtml form magento file structure

Config file

Add the new class in config file as shown in below image.

override adminhtml form magento

Rewrite admin form

Extend the parent class and add the additional fields in form


require_once 'Vsourz/Imagegallery/Block/Adminhtml/Image/Edit/Tabs/Form.php';

class Addpeople_Imagegalleryext_Block_Adminhtml_Image_Edit_Tabs_Form 
        extends Vsourz_Imagegallery_Block_Adminhtml_Image_Edit_Tabs_Form {
    protected function _prepareForm() {
        if (Mage::registry('image_data')) {
            $data = Mage::registry('image_data')->getData();
        } else {
            $data = array();
        $form = $this->getForm();
        $fieldset = $form->addFieldset('imagegalleryext_image', array('legend' => Mage::helper('imagegalleryext')->__('Additional Fields')));  
        $fieldset->addField('filters_workshop_colour', 'select', array(
            'label'     => Mage::helper('imagegalleryext')->__('Filters Workshop Colour'),
            'class'     => 'required-entry',
            'required'  => true,
            'name'      => 'filters_workshop_colour',
            'value'  => '0',
            'values' => array('0' => 'Yes','1' => 'No'),
            'disabled' => false,
            'readonly' => false,          
        return $this;

Share this Tutorial