1

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 happenenter image description here

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();
  }
}
1

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:

protected function _prepareForm()
{
    $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
    $form->setUseContainer(true);
    $this->setForm($form);
    return parent::_prepareForm();
}

Make sure that the id you pass to the Varien_Data_Form constructor is edit_form.
Use the cms page module as an example: (Mage_Adminhtml_Block_Cms_Page_Edit_Form).

| improve this answer | |
  • yes i have same code in this file – Vikrant Roy May 6 '14 at 8:34
  • @VikrantRoy. I see that you set a custom template to the form $this->setTemplate('XXXX/form.phtml');. Try removing that and see what happens. If you have some code in form.phtml that you absolutely need you might want to post the contents of that file in the question also. – Marius May 6 '14 at 8:38
  • i have tried this but still same output – Vikrant Roy May 6 '14 at 8:39
  • it has been fixed i was set wrong key element form_id instead of id thanks @Marius – Vikrant Roy May 6 '14 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.