Magento Admin Grid Edit Form Display on Left Side – How to Fix

adminadmin-paneladminformadminhtmlgrid

Hi i am not so familer with magento , so i am getting some problem in magento admin grid

problem is admin grid edit form is displaying on left side with tabs like in image below

Thanks in advance for help
enter image description here

my code is here
Ooorza/PaypalAdaptivePayment/controllers/AdminhtmlTransactionController.php

<?php

class Ooorza_PaypalAdaptivePayment_Adminhtml_TransactionController extends Mage_Adminhtml_Controller_action
{

    protected function _initAction() {
        $this->loadLayout()
            ->_setActiveMenu('adaptivepayment');
            $this->_addContent($this->getLayout()->createBlock('paypaladaptivepayment/adminhtml_transaction'));
            //->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));

        return $this;
    }   

    public function indexAction() {
        $this->_initAction()
            ->renderLayout();
    }

    public function editAction() {
        $id     = $this->getRequest()->getParam('id');
        $model  = Mage::getModel('paypaladaptivepayment/paytransaction')->load($id);

        if ($model->getId() || $id == 0) {
            $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
            if (!empty($data)) {
                $model->setData($data);
            }

            Mage::register('adaptivetransaction_data', $model);

            $this->loadLayout();
            $this->_setActiveMenu('adaptivepayment');

            $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
            $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));

            $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);

            $this->_addContent($this->getLayout()->createBlock('paypaladaptivepayment/adminhtml_transaction_edit'))
                ->_addLeft($this->getLayout()->createBlock('paypaladaptivepayment/adminhtml_transaction_edit_tabs'));

            $this->renderLayout();
        } else {
            Mage::getSingleton('adminhtml/session')->addError(Mage::helper('paypaladaptivepayment')->__('Item does not exist'));
            $this->_redirect('*/*/');
        }
    }

    public function newAction() {
        $this->_forward('edit');
    }

    public function saveAction() {
        echo "string";
    }

    public function deleteAction() {

    }

    public function massDeleteAction() {

    }

    public function massStatusAction()
    {

    }

    public function exportCsvAction()
    {
        $fileName   = 'adaptivetransaction.csv';
        $content    = $this->getLayout()->createBlock('paypaladaptivepayment/adminhtml_transactions
            _grid')
            ->getCsv();

        $this->_sendUploadResponse($fileName, $content);
    }

    public function exportXmlAction()
    {
        $fileName   = 'adaptivetransaction.xml';
        $content    = $this->getLayout()->createBlock('paypaladaptivepayment/adminhtml_transaction_grid')
            ->getXml();

        $this->_sendUploadResponse($fileName, $content);
    }

    protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
    {
        $response = $this->getResponse();
        $response->setHeader('HTTP/1.1 200 OK','');
        $response->setHeader('Pragma', 'public', true);
        $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
        $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
        $response->setHeader('Last-Modified', date('r'));
        $response->setHeader('Accept-Ranges', 'bytes');
        $response->setHeader('Content-Length', strlen($content));
        $response->setHeader('Content-type', $contentType);
        $response->setBody($content);
        $response->sendResponse();
        die;
    }
}

Ooorza/PaypalAdaptivePayment/Block/Adminhtml/Transaction.php

<?php
class Ooorza_PaypalAdaptivePayment_Block_Adminhtml_Transaction extends Mage_Adminhtml_Block_Widget_Grid_Container
{
  public function __construct()
  {
    $this->_controller = 'adminhtml_transaction';
    $this->_blockGroup = 'paypaladaptivepayment';
    $this->_headerText = Mage::helper('paypaladaptivepayment')->__('Item Manager');
    $this->_addButtonLabel = Mage::helper('paypaladaptivepayment')->__('Add Item');
    parent::__construct();
  }
}

Ooorza/PaypalAdaptivePayment/Block/Adminhtml/Transaction/Grid.php

<?php

class Ooorza_PaypalAdaptivePayment_Block_Adminhtml_Transaction_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
  public function __construct()
  {
      parent::__construct();
      $this->setId('adaptivepaymentGrid');
      $this->setDefaultSort('adaptivepayment_id');
      $this->setDefaultDir('ASC');
      $this->setSaveParametersInSession(true);
  }

  protected function _prepareCollection()
  {
      $collection = Mage::getModel('paypaladaptivepayment/paytransaction')->getCollection();
      $this->setCollection($collection);
      return parent::_prepareCollection();
  }

  protected function _prepareColumns()
  {
      $this->addColumn('pay_id',
             array(
                    'header' => 'ID',
                    'align' =>'right',
                    'width' => '50px',
                    'index' => 'pay_id',
               ));
       $this->addColumn('order_id',
               array(
                    'header' => 'Order ID',
                    'align' =>'left',
                    'index' => 'order_id',
              ));
       $this->addColumn('transaction_id', array(
                    'header' => 'transaction id',
                    'align' =>'left',
                    'index' => 'transaction_id',
             ));
        $this->addColumn('paykey', array(
                     'header' => 'paykey',
                     'align' =>'left',
                     'index' => 'paykey',
          ));

        $this->addColumn('transaction_status', array(
                     'header' => 'transaction_status',
                     'align' =>'left',
                     'index' => 'transaction_status',
          ));

        $this->addColumn('currency', array(
                     'header' => 'currency',
                     'align' =>'left',
                     'index' => 'currency',
          ));

        $this->addColumn('amount', array(
                     'header' => 'amount',
                     'align' =>'left',
                     'index' => 'amount',
          ));

        $this->addColumn('vendor_mail', array(
                     'header' => 'vendor_mail',
                     'align' =>'left',
                     'index' => 'vendor_mail',
          ));

        $this->addColumn('sender_mail', array(
                     'header' => 'sender_mail',
                     'align' =>'left',
                     'index' => 'sender_mail',
          ));

        $this->addExportType('*/*/exportCsv', Mage::helper('paypaladaptivepayment')->__('CSV'));
        $this->addExportType('*/*/exportXml', Mage::helper('paypaladaptivepayment')->__('XML'));

      return parent::_prepareColumns();
  }

    protected function _prepareMassaction()
    {
        $this->setMassactionIdField('custom_id');
        $this->getMassactionBlock()->setFormFieldName('custom');

        $this->getMassactionBlock()->addItem('delete', array(
             'label'    => Mage::helper('custom')->__('Delete'),
             'url'      => $this->getUrl('*/*/massDelete'),
             'confirm'  => Mage::helper('custom')->__('Are you sure?')
        ));

        $statuses = Mage::getSingleton('custom/status')->getOptionArray();

        array_unshift($statuses, array('label'=>'', 'value'=>''));
        $this->getMassactionBlock()->addItem('status', array(
             'label'=> Mage::helper('custom')->__('Change status'),
             'url'  => $this->getUrl('*/*/massStatus', array('_current'=>true)),
             'additional' => array(
                    'visibility' => array(
                         'name' => 'status',
                         'type' => 'select',
                         'class' => 'required-entry',
                         'label' => Mage::helper('custom')->__('Status'),
                         'values' => $statuses
                     )
             )
        ));
        return $this;
    }

  public function getRowUrl($row)
  {
      return $this->getUrl('*/*/edit', array('id' => $row->getId()));
  }

}

Ooorza/PaypalAdaptivePayment/Block/Adminhtml/Transaction/Edit.php

<?php

class Ooorza_PaypalAdaptivePayment_Block_Adminhtml_Transaction_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
    public function __construct()
    {
        parent::__construct();

        $this->_objectId = 'id';
        $this->_blockGroup = 'custom';
        $this->_controller = 'adminhtml_custom';

        $this->_updateButton('save', 'label', Mage::helper('custom')->__('Save Item'));
        $this->_updateButton('delete', 'label', Mage::helper('custom')->__('Delete Item'));

        $this->_addButton('saveandcontinue', array(
            'label'     => Mage::helper('adminhtml')->__('Save And Continue Edit'),
            'onclick'   => 'saveAndContinueEdit()',
            'class'     => 'save',
        ), -100);


    }

    public function getHeaderText()
    {
        if( Mage::registry('custom_data') && Mage::registry('custom_data')->getId() ) {
            return Mage::helper('custom')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('custom_data')->getTitle()));
        } else {
            return Mage::helper('custom')->__('Add Item');
        }
    }
}

Ooorza/PaypalAdaptivePayment/Block/Adminhtml/Transaction/Edit/Tabs.php

<?php

class Ooorza_PaypalAdaptivePayment_Block_Adminhtml_Transaction_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
{

  public function __construct()
  {
      parent::__construct();
      $this->setId('adaptivetransaction_tabs');
      $this->setDestElementId('adaptivetransaction_edit_form');
      $this->setTitle(Mage::helper('paypaladaptivepayment')->__('Item Information'));
  }

  protected function _beforeToHtml()
  {
      $this->addTab('form_section', array(
          'label'     => Mage::helper('paypaladaptivepayment')->__('Item Information'),
          'title'     => Mage::helper('paypaladaptivepayment')->__('Item'),
          'content'   => $this->getLayout()->createBlock('paypaladaptivepayment/adminhtml_transaction_edit_tab_form')->toHtml(),
      ));

      return parent::_beforeToHtml();
  }
}

Ooorza/PaypalAdaptivePayment/Block/Adminhtml/Transaction/Edit/Form.php

<?php

class Ooorza_PaypalAdaptivePayment_Block_Adminhtml_Transaction_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
  protected function _prepareForm()
  {
      $form = new Varien_Data_Form(array(
                                      'id' => 'edit_form',
                                      'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
                                      'method' => 'post',
                                      'enctype' => 'multipart/form-data'
                                   )
      );

      $form->setUseContainer(true);
      $this->setForm($form);
      return parent::_prepareForm();
  }
}

Ooorza/PaypalAdaptivePayment/Block/Adminhtml/Transaction/Edit/tab/Form.php

<?php

class Ooorza_PaypalAdaptivePayment_Block_Adminhtml_Transaction_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
  protected function _prepareForm()
  {
      $form = new Varien_Data_Form();
      $this->setForm($form);
      $fieldset = $form->addFieldset('adaptivetransaction_form', array('legend'=>Mage::helper('paypaladaptivepayment')->__('Item information')));

      $fieldset->addField('order_id', 'text', array(
          'label'     => Mage::helper('paypaladaptivepayment')->__('Oder ID'),
          'class'     => 'required-entry',
          'required'  => true,
          'name'      => 'order_id',
      ));

      $fieldset->addField('transaction_id', 'text', array(
          'label'     => Mage::helper('paypaladaptivepayment')->__('Transaction ID'),
          'class'     => 'required-entry',
          'required'  => true,
          'name'      => 'transaction_id',
      ));

      if ( Mage::getSingleton('adminhtml/session')->getCustomData() )
      {
          $form->setValues(Mage::getSingleton('adminhtml/session')->getAdaptivetransactionData());
          Mage::getSingleton('adminhtml/session')->setAdaptivetransactionData(null);
      } elseif ( Mage::registry('adaptivetransaction_data') ) {
          $form->setValues(Mage::registry('adaptivetransaction_data')->getData());
      }
      return parent::_prepareForm();
  }
}

Best Answer

Try with this:

In the class Ooorza_PaypalAdaptivePayment_Block_Adminhtml_Transaction_Edit_Tabs replace this line

$this->setDestElementId('adaptivetransaction_edit_form');

with

$this->setDestElementId('edit_form');
Related Topic