I am working on magento admin. Try to adding grid with add edit action. But I am stuck at strange issue my form is display in left sidebar under selected tab. Don't know why this happen. Please help me if you know why this is happen
Code of XXXX/XXX/Block/Adminhtml/Dragon/Edit/Form.php
<?php
class XXXX_XXX_Block_Adminhtml_Dragon_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
$form = new Varien_Data_Form(array(
'form_id' => 'edit_form',
'action' => $this->getUrl('*/*/save', array('form_id' => $this->getRequest()->getParam('form_id'))),
'method' => 'post',
'enctype' => 'multipart/form-data'
)
);
$form->setUseContainer(true);
$this->setForm($form);
$this->setTemplate('XXXX/form.phtml');
return parent::_prepareForm();
}
}
Best Answer
In your extension you should have this file:
[Namespace]/[Module]/Block/Adminhtml/[Entity]/Edit/Form.php
or something similar. This is the form container class.Inside that file you should have a method
_prepareForm
that should look like this:Make sure that the
id
you pass to theVarien_Data_Form
constructor isedit_form
.Use the cms page module as an example: (
Mage_Adminhtml_Block_Cms_Page_Edit_Form
).