1

I am trying to add a grid in my admin form tab. the idea is that the top part of page will hold the form and the bottom part will have the grid.

example of it is: enter image description here

I obtained the instructions on how to do this from here

In summary I added a renderer via the $fieldset->addType to my form.

The form rendered okay, but no grid.

example code

$fieldset->addType('customer_grid', 'test_testmodule_Block_Adminhtml_config_Edit_Form_Renderer_Fieldset_config');

i.e

class test_testmodule_Block_Adminhtml_config_Edit_Tab_config extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
    {
        $form = new Varien_Data_Form();
        $this->setForm($form);

        # add a fieldset, this returns a Varien_Data_Form_Element_Fieldset object
        $fieldset = $form->addFieldset('base_fieldset', array(
            'legend' => Mage::helper('test_testmodule')->__('test')
        ));

      $fieldset->addType('customer_grid',
> 'test_testmodule_Block_Adminhtml_config_Edit_Form_Renderer_Fieldset_config');

   .......Form Fieldsets 

         return parent::_prepareForm();
    }

I then created a page for creation of form grid.

    public function getElementHtml()
    {
        return Mage::helper('core')->getLayout()->createBlock('test_testmodule/adminhtml_payment_edit_form_renderer_fieldset_config_grid')->toHtml();
    }
}

FINALLY

I created the grid page.

<?php
class test_testmodule_Block_Adminhtml_config_Edit_Tab_config_Grid extends Mage_Adminhtml_Block_Widget_Grid
{

    public function __construct()
    {
        parent::__construct();
        $this->setId('customerGrid');
        $this->setUseAjax(true);
        $this->setDefaultSort('entity_id');
        $this->setSaveParametersInSession(true);
    }

    protected function _prepareCollection()
    {
      $collection = Mage::getResourceModel('test_testmodule/config')->getCollection();      
      $this->setCollection($collection);
      return parent::_prepareCollection();
    }

    protected function _prepareColumns()
    {
    ..........collection values     
    }

}

I suspect the problem is from the $fieldset->addType - it is simply not rendering the block

Your Answer

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

Browse other questions tagged or ask your own question.