Which i am creating form to save data in table but it is displaying it in left side in tab section in my custom module,
Grid Container
Block/Adminhtml/Grid.php
class Custom_Abc_Block_Adminhtml_Customize extends Mage_Adminhtml_Block_Widget_Grid_Container
{
/**
* constructor
*
* @access public
* @return void
* @author Custom
*/
public function __construct()
{
$this->_controller = 'adminhtml_abc_customize_customize';
$this->_blockGroup = 'custom_abc';
$this->_headerText = Mage::helper('custom_abc')->__('Custom Abc');
$this->_addButtonLabel = Mage::helper("custom_abc")->__("Add Custom Abc");
parent::__construct();
}
}
Block/Adminhtml/Customize/Edit.php
class Custom_Abc_Block_Adminhtml_Customize_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
public function __construct()
{
parent::__construct();
$this->_objectId = 'id';
$this->_blockGroup = 'custom_abc';
$this->_controller = 'adminhtml_abc_customize_customize';
$this->_updateButton(
'save',
'label',
Mage::helper('custom_abc')->__('Save Custom')
);
$this->_updateButton(
'delete',
'label',
Mage::helper('custom_abc')->__('Delete Custom')
);
$this->_addButton(
'saveandcontinue',
array(
'label' => Mage::helper('custom_abc')->__('Save And Continue Edit'),
'onclick' => 'saveAndContinueEdit()',
'class' => 'save',
),
-100
);
$this->_formScripts[] = "
function saveAndContinueEdit() {
editForm.submit($('edit_form').action+'back/edit/');
}
";
}
public function getHeaderText()
{
if (Mage::registry('current_custom') && Mage::registry('current_custom')->getId()) {
return Mage::helper('custom_custom')->__(
"Edit Custom '%s'",
$this->escapeHtml(Mage::registry('current_custom')->getTin())
);
} else {
return Mage::helper('custom_abc')->__('Add Custom');
}
}
}
Block/Adminhtml/Customize/Edit/tabs.php
class Custom_Abc_Block_Adminhtml_Customize_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
public function __construct() {
parent::__construct();
$this->setId('custom_info_tabs');
$this->setDestElementId('edit_form');
$this->setTitle(Mage::helper('custom_abc')->__('Custom Information'));
}
protected function _beforeToHtml() {
$this->addTab("form_section", array(
"label" => Mage::helper("custom_abc")->__("Custom Abc Information"),
"title" => Mage::helper("custom_abc")->__("Custom Abc Information"),
"content" => $this->getLayout()->createBlock("custom_abc/adminhtml_customize_edit_tab_form")->toHtml(),
));
return parent::_beforeToHtml();
}
}
Block/Adminhtml/Customize/Edit/form.php
class Custom_Abc_Block_Adminhtml_Customize_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
protected function _prepareForm() {
$form = new Varien_Data_Form(array(
"id" => "edit_form",
"action" => $this->getUrl("adminhtml/abc_customize_customize/save", array("id" => $this->getRequest()->getParam("id"))),
"method" => "post",
"enctype" => "multipart/form-data",
)
);
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
}
Block/Adminhtml/Customize/Edit/Tab/form.php
class Custom_Abc_Block_Adminhtml_Customize_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
protected function _prepareForm() {
$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset("custom_form", array("legend" => Mage::helper("custom_abc")->__("Add Custom Abc")));
$fieldset->addField("custom_id", "text", array(
"label" => Mage::helper("custom_abc")->__("Custom Id"),
"name" => "custom_id",
));
if (Mage::getSingleton("adminhtml/session")->getCustomData()) {
$form->setValues(Mage::getSingleton("adminhtml/session")->getCustomData());
Mage::getSingleton("adminhtml/session")->setCustomData(null);
} elseif (Mage::registry("current_Custom")) {
$form->setValues(Mage::registry("current_Custom")->getData());
}
return parent::_prepareForm();
}
}
controllers/Adminhtml/Abc/Customize/CustomizeController.php
class Custom_Abc_Adminhtml_Abc_Customize_CustomizeController extends Mage_Adminhtml_Controller_Action {
public function indexAction() {
$this->loadLayout();
$this->renderLayout();
}
public function newAction() {
$this->_title($this->__("Custom"));
$this->_title($this->__("Custom"));
$this->_title( $this->__("New Item"));
$id = $this->getRequest()->getParam("id");
$model = Mage::getModel("custom_abc/custom")->load($id);
$data = Mage::getSingleton("adminhtml/session")->getFormData(true);
if (!empty($data)) {
$model->setData($data);
}
Mage::register("current_custom", $model);
$this->loadLayout();
$this->_setActiveMenu("custom_abc/abcd");
$this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
$this->_addBreadcrumb(Mage::helper("adminhtml")->__("Custom Manager"), Mage::helper("adminhtml")->__("Custom Manager"));
$this->_addBreadcrumb(Mage::helper("adminhtml")->__("Custom Description"), Mage::helper("adminhtml")->__("Custom Description"));
$this->_addContent($this->getLayout()->createBlock("custom_abc/adminhtml_customize_edit"))->_addLeft($this->getLayout()->createBlock("custom_abc/adminhtml_customize_edit_tabs"));
$this->renderLayout();
}
}
Best Answer
problem with your
$this->_controller = 'adminhtml_abc_customize_customize';
change to$this->_controller = 'adminhtml_customize';