Admin – How to Show Form Instead of Grid

adminformsgrid

I'am a newbie to Magento. I stacked on followed problem: i have db table with config settings (name/value) and want add functionality to change this data via admin area. By default, when I click on menu item "Config" data showing as grid ie as a table with 2 columns and when I click on row, I see the form, where I can change only one pair name/value. But I want to change all values at one page like System-Tools-Compilation. Please help me to solve this task.

UPD:

I create a controller:

app\code\local\PCG\Mod\controllers\Adminhtml\ConfigController.php with following code:

class PCG_Mod_Adminhtml_ConfigController extends Mage_Adminhtml_Controller_Action

    public function indexAction()
    {
        $this->loadLayout();
        $this->_setActiveMenu('pcgmod');
        $this->_addContent($this->getLayout()->createBlock('pcgmod/adminhtml_config_edit'));
        $this->renderLayout();
    }

}

Then create Edit block:

../Block/Adminhtml/Config/Edit.php with following code:

class PCG_Mod_Block_Adminhtml_Config_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {

    public function __construct()
    {
        echo "edit works";
        parent::__construct();
        $this->_controller = 'adminhtml_config';
        $this->_updateButton('save', 'label', Mage::helper('adminhtml')->__('Save config'));
        $this->_removeButton('reset');
        $this->_removeButton('back');
    }
}

After that I create form:
..Block/Adminhtml/Config/Edit/Form.php with following code:

class PCG_Mod_Block_Adminhtml_Config_Edit_Form extendsMage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
    {
       echo "form works";
    }
}

I expect to see "form works", but I see only "edit works". What I do wrong?

Best Answer

Yes I have done same functionality in one of my project. hope you have create the basic module with grid.

Changes in Exciting code For Example.

Step 1: Open your Controller app\code\local\[Package Name]\[Module Name]\controllers\Adminhtml\ImportController.php

Step 2: Each Controller has indexAction().

public function indexAction()
{
    $this->_title($this->__('Import'));
    $this->loadLayout();
    $this->_addContent($this->getLayout()->createBlock('packagename/adminhtml_import_edit'));
    $this->renderLayout();
}

block path as per Magento Standard. For this you can bypass the grid thing.

Step 3: create file app\code\community\[Package Name]\[Module Name]\Block\Adminhtml\import\Edit.php.

Step 4: They layout and template file as per Magento Standards.

<packagename_adminhtml_import>
    <reference name="content">
        <block type="packagename/adminhtml_import" name="import" />
    </reference>
</packagename_adminhtml_import>

Hope you can understand What I am trying to say. For Your Knowledge I have follow the structure of System >> My Account page.