Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5959251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:39:30+00:00 2026-05-22T18:39:30+00:00

I need to create module in Magento which will have few database tables. One

  • 0

I need to create module in Magento which will have few database tables. One of the function of the module is adding multiple images.
For example while being on the “Add new item” or “Edit item” page in the admin, from the left side I have tabs, one of them is “Item Images“. When being clicked I want the content of this tab to be my own custom one.
After digging into the code, found out that the way it renders this content, Magento is using one of the Varien_Data_Form_Element classes for each element in the full form. I want to add my own class here that will render form elements the way I want.
Is this a good practice to do so, or there is some other more elegant way of adding own content in the admin forms?
EDIT: I must add that none of the existing classes is helping my problem.

SOLUTION EDIT:
I have a controller in my custom module that is in Mypackage/Mymodule/controllers/Adminhtml/Item.php. In the editAction() method which I am using for adding and creating new items, I am creating 2 blocks, one for the form and one left for the tabs:

$this->_addContent($this->getLayout()->createBlock('item/adminhtml_edit'))
                    ->_addLeft($this->getLayout()->createBlock('item/adminhtml_edit_tabs'));
$this->renderLayout();

The Block/Adminhtml/Edit/Tabs.php block is creating 2 tabs on the left: General Info and Item Images, each of them are rendering different content on the right side using Block classes.

protected function _beforeToHtml()
{
   $this->addTab('item_info', array(
        'label' => Mage::helper('mymodule')->__('Item Info'),
        'content'=> $this->getLayout()->createBlock('item/adminhtml_edit_tab_form')->toHtml(),
        ));

   $this->addTab('item_images', array(
        'label' => Mage::helper('mymodule')->__('Item Images'),
        'active' => ( $this->getRequest()->getParam('tab') == 'item_images' ) ? true : false,
        'content' => $this->getLayout()->createBlock('item/adminhtml_images')->toHtml(),
        ));

   return parent::_beforeToHtml();
}

I wanted the tab item_images to render my own form elements and values, not the default varien form elements.

class Mypackage_Mymodule_Block_Adminhtml_Images extends Mage_Core_Block_Template
{
    public function __construct()
    {
        parent::__construct();
        $this->setTemplate('item/images.phtml'); //This is in adminhtml design
    }


    public function getPostId()
    {
    return $this->getRequest()->getParam('id');
    }

    public function getExistingImages()
    {
        return Mage::getModel('mymodule/item')->getImages($this->getPostId());
    }
}

Then in the template app/design/adminhtml/default/default/template/item/images.phtml you can use these values:

//You can add your own custom form fields here and all of them will be included in the form
foreach($this->getExistingImages() as $_img):
//Do something with each image
endforeach;
//You can add your own custom form fields here and all of them will be included in the form
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:39:31+00:00Added an answer on May 22, 2026 at 6:39 pm

    No, it’s not. You should never edit or add to files that provided by a vendor. If you absolutely must replace a class file you should use the local code pool. For example, if you wanted to change the behavior of a text field,

    lib/Varien/Data/Form/Element/Text.php
    

    You should place a file in the local or community code pool

    app/code/local/Varient/Data/Form/Element/Text.php
    

    However, doing the replaces the class, and it becomes your responsibility to maintain compatibility with future versions. That means if Magento Inc. changes lib/Varien/Data/Form/Element/Text.php, you need to update your version to be compatible.

    Based on what you said I’d look into creating a class rewrite for the Block class that renders the form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a batch file which starts multiple console applications in a
I need to create a python module that will be installed on end-user machines.
Hi I need to create a module in drupal to display some data, not
I need to create a linked server to a DB2 database on a mainframe.
I need to create an ASP page (classic, not ASP.NET) which runs remote shell
I need to create a backup of a SQL Server 2005 Database that's only
I’m having a lot of trouble understanding how to create a module that will
I need to create a historical timeline starting from 1600's to the present day.
I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I need to create a 2D int array of size 800x800. But doing so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.