0
votes

I am new to magento and now trying to create forms in Admin getting the error

exception 'Mage_Core_Exception' with message 'Invalid block type: Mage_Tamodule_Block_Adminhtml_Event_Edit' in C:\xampp\htdocs\mg\magento\app\Mage.php:595

<?php
class Ta_TaModule_Adminhtml_EventController extends 
Mage_Adminhtml_Controller_Action{
public function indexAction(){      
$this->loadLayout();        
$this->_addContent(
$this->getLayout()->createBlock('tamodule/adminhtml_event_edit')
);
return $this->renderLayout();
}
}   


<?php
class Ta_Tamodule_Block_Adminhtml_Event_Edit extends 
Mage_Adminhtml_Block_Widget_Form_Container
{
public function __construct()
{
    $this->_objectId = 'event_id';
    $this->_blockGroup = 'tamodule';  
    $this->_controller = 'adminhtml_event';

    parent::__construct();
}

/**
 * Get edit form container header text
 *
 * @return string
 */
public function getHeaderText()
{
    return Mage::helper('tamodule')->__('New Event');
}
}

Please note there is no layout as per the tutorials am following and hence i have not created any layout in adminhtml/default/default/layout. My config.xml as follows - please note this has many other things too.

<?xml version="1.0"?>
<config>
<modules>
<Ta_TaModule>
<version>0.0.0</version>
</Ta_TaModule>
</modules>
<global>
<blocks>
<TaModule>
<class>Ta_TaModule_Model</class>
</TaModule>
</blocks>       
<helpers>
<TaModule>
<class>Ta_TaModule_Helper</class>
</TaModule>
</helpers>
<events>
<catalog_product_save_after>
<observers>
<Ta_TaModule>
<class>TaModule/observer</class>
<method>logUpdate</method>
<type>singleton</type>
</Ta_TaModule>
</observers>
</catalog_product_save_after>
</events>
<models>
<TaModule>
<class>Ta_TaModule_Model</class>
<resourceModel>tamodule_resource</resourceModel>
</TaModule>
<tamodule_resource>
<class>Ta_TaModule_Model_Resource</class>
<entities>
<TaModule>
<table>Tamodule_event</table>
</TaModule>
</entities>
</tamodule_resource>
</models>

</global>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<tamodule before="Mage_Adminhtml">Ta_TaModule_Adminhtml</tamodule>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<frontend>
<routers>
<tamodule>
<use>standard</use>
<args>
<frontName>tamodule</frontName>
<module>Ta_TaModule</module>
</args>
</tamodule>
</routers>
<layout>
<updates>
<tamodule>
<file>example.xml</file>
</tamodule>
</updates>
</layout>
</frontend>
</config>

I also noticed var_dump($this->getLayout()->createBlock('tamodule/adminhtml_event_edit')) return bool(false)

1

1 Answers

0
votes

Issue resolved when i created a separate module for the custom Admin Form.

I really do not know what went wrong when i had too many coding clubbed, however there are few things i figured out which a new-bee must do. 1) Always enable the developer mode. 2) Pay close attention to var/log/system.log & exception. 3) If you are in the learning stage, practise the lesson as mentioned in the tutorials ( most of the cases it works). Reason being there are few times we make cap / small mistakes & path mistakes, which leads to unnecessary waste of time.

4) try to make use of multiple echo / capturing exceptions etc in the code.

Even after making a separate module, i did compare the code structure, folder structure and everything were same, just that i separated this menu item alone to a different folder.

Use the above if you are getting 2 issues which i encountered and moving to a separate module helped. 1) If you end up with a invalid block type = please note the error starts with Mage_** block not found. To correct this in the controller, try giving the full block and 2) next it will throw error in the Helper stating Mage___Helper not found.