You have to add the fields in _prepareForm()
in \NameSpace\ModuleName\Block\Adminhtml\ModuleName\Edit\Tab\Form.php
add the below code.
$fieldset->addField('<Data base Field name>', 'image', array(
'label' => Mage::helper('<Module Name>')->__('Logo'),
'name' => '<your Data base Field name>',
'note' => '(*.jpg, *.png, *.gif)'
));
You haven't attached your layout xml file. If you have the correct layout set there, then you are almost there. But until you don't see any error messages in your log files your layout is not correctly set. Why to expect errors in the logs? When you want to show a tab and you implement the Mage_Adminhtml_Block_Widget_Tab_Interface
, you have to write the interface's methods: getTabLabel
, getTabTitle
, canShowTab
, isHidden
. I don't see these methods in your Mycontrol.php
block. Also you must have a container for the tabs' content. Have a look at /app/design/adminhtml/default/default/layout/catalog.xml
and see how it is implemented there the layout xml at node adminhtml_catalog_product_new
. You will see there something like:
<adminhtml_catalog_product_new>
<update handle="editor"/>
<reference name="content">
<block type="adminhtml/catalog_product_edit" name="product_edit"></block>
</reference>
<reference name="left">
<block type="adminhtml/catalog_product_edit_tabs" name="product_tabs"></block>
</reference>
<reference name="js">
<block type="adminhtml/catalog_product_edit_js" template="catalog/product/js.phtml" name="catalog_product_js"></block>
<block type="core/template" template="catalog/wysiwyg/js.phtml"/>
</reference>
</adminhtml_catalog_product_new>
What you are interested in is the left
reference and the content
. First, look at the adminhtml/catalog_product_edit_tabs
block class' constructor. You will see:
public function __construct()
{
parent::__construct();
$this->setId('product_info_tabs');
$this->setDestElementId('product_edit_form');
$this->setTitle(Mage::helper('catalog')->__('Product Information'));
}
with the setDestElementId
you set the id of the element which will contain the contents while clicking on a tab. Also in this class you can define a _prepareLayout
method and add the tab to the layout:
$this->addTab('some_name', array(
'label' => Mage::helper('your_helper')->__('tab label'),
'content' => $this->_translateHtml($this->getLayout()
->createBlock('mycomp/myext_mycontrol')->toHtml()),
));
You can add a tab also from the layout xml by using the <action method="addTab">
. You can see a couple of examples in catalog.xml
.
Now that your tab is added, you have to make sure that the container id (what you have specified in the setDestElementId
method) does exist. So, go back to the adminhtml_catalog_product_new
layout example, see the reference to the content
; the block inside should produce the needed id.
When these are all set, your tabs will work.
Best Answer
The tabs are added in
Mage_Adminhtml_Block_Dashboard_Grids::_prepareLayout
.Here is how a tab structure looks like:
You can add tab that does not retrieve data through ajax.
What you can do is to override the method above and add your own tabs (content or ajax).
[EDIT]
Here is how you can override a block And in your new block do this:
[Second degree edit]
Here is a small sample module that does this. Let's call it
Easylife_Test
.app/etc/modules/Easylife_Test.xml
- the declaration fileapp/code/local/Easylife/Test/etc/config.xml
- the configuration fileapp/code/local/Easylife/Test/Block/Adminhtml/Dashboard/Grids.php
- the new block