0

I am creating custom admin module where grid, edit, new, delete work as same as product grid. Everything working fine but when i click on grid row to edit item it redirects correctly but the text field does't contains data. currently i am having one field called name my editAction as follows:

public function editAction()
    {
     $id = $this->getRequest()->getParam('id', null);
        $model = Mage::getModel('fondation/fondation');
        if ($id) {
            $model->load((int) $id);
            if ($model->getId()) {
                $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
                if ($data) {
                    $model->setData($data)->setId($id);
                }
            } else {
                Mage::getSingleton('adminhtml/session')->addError(Mage::helper('fondation')->__('Example does not exist'));              $this->_redirect('*/*/');
            }
        }
        Mage::register('fondation_data', $model);
        $this->loadLayout();
        $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
        $this->renderLayout();
}
0

Please check if the controller name is correct

Try adding this action before editAction

public function newAction()
    {
        $this->_forward('edit');
    }
  • Yes, Done that, but Problem still exist:{ – Charlie May 9 '14 at 11:46
  • I suggest you should update other code as well, so that exact issue is debugged – TBI Infotech May 9 '14 at 12:14
  • I got the answer but SE not allowing me to answer Users with less than 10 reputation can't answer their own question for 8 hours after asking. You can answer 5/9/2014 3:35:53 PM. Until then please use comments, or edit your question instead. – Charlie May 9 '14 at 12:23
  • Good that your issue is resolved – TBI Infotech May 9 '14 at 12:26
  • Yeah, Thank You.. – Charlie May 9 '14 at 12:38
0

I got the answer!! Its Problem of Form and admin session.

Here is my Code the commented lines are the issue, and my previous code..

class Npm_Fondation_Block_Adminhtml_Fondation_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
    {
        $fondation = Mage::registry('fondation_data');
        $form = new Varien_Data_Form();
        //$this->setForm($form);
        $fieldset = $form->addFieldset('fondation_form', array('legend'=>Mage::helper('fondation')->__('General')));

        $fieldset->addField('name', 'text', array(
          'label'     => Mage::helper('fondation')->__('Name'),
          'class'     => 'required-entry',
          'required'  => true,
          'name'      => 'name',
        ));
        $this->setForm($form);
        $form->setValues($fondation->getData());
        /*if (Mage::getSingleton('adminhtml/session')->getFondationData()) {
            $form->setValues(Mage::getSingleton('adminhtml/session')->getFondationData());
            Mage::getSingleton('adminhtml/session')->setFondationData(null);
        } elseif (Mage::registry('fondation_data')) {
            $form->setValues(Mage::registry('fondation_data')->getData());
        }*/
        return parent::_prepareForm();
    }
}

Thanks for everyone :)

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.