I am new to magento, I have created custom module front and backend(admin) module, working fine except edit.

in grid bind the data correctly with id


but when I click on edit I redirected to edit page and I did debug also, but record id is not getting.

public function editAction()
        $testId = $this->getRequest()->getParam('test_id');
        //id is not getting
        $testModel = Mage::getModel('quotes/quotes')->load($testId);

if I pass/hard coded from here I got a details of record id

$testModel = Mage::getModel('quotes/quotes')->load(1);

can any one tell me where I went wrong?



What index did you give your entity?

$id  = $this->getRequest()->getParam('id');

I usually use id as a primary key, and am able to load it by getting the associated paramter.

As per comment:

public function editAction()
    $testId = $this->getRequest()->getParam('test_id');
    $testModel = Mage::getModel('quotes/quotes')->load($testId);
    $data = Mage::getSingleton('adminhtml/session')->getQuotesData(true);
    if (!empty($data)) {

    Mage::register('quotes_quotes', $testModel);
        ->_addContent($this->getLayout()->createBlock('quotes_quotes/adminhtml_quotes_edit')->setData('action', $this->getUrl('*/*/save')))

Then in your form file


 protected function _prepareForm()
    $model = Mage::registry('wootware_inventorymanagement');
     $form = new Varien_Data_Form(array(
        'id'        => 'edit_form',
        'action'    => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('test_id'))),
        'method'    => 'post'

    $fieldset = $form->addFieldset('base_fieldset', array(
        'legend'    => Mage::helper('checkout')->__('Quotes'),
        'class'     => 'fieldset-wide',

    if ($model->getId()) {
        $fieldset->addField('id', 'hidden', array(
            'name' => 'id',
| improve this answer | |
  • my primary key is test_id. here I am not getting record id. – Magento Nav Feb 6 '14 at 13:18
  • So when you click the record in grid view, you get directed to the edit page but the fields aren't populated with the data? – Moose Feb 6 '14 at 13:19
  • yah! if i hard code I got result otherwise not getting. – Magento Nav Feb 6 '14 at 13:20
  • see the updated answer, let me know if that proves useful – Moose Feb 6 '14 at 13:22
  • from where i write this code. – Magento Nav Feb 6 '14 at 13:23

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.