0

I am Created one custom module but Edit Action Can not work ?

Here is my Controller

public function editAction()
    {
        echo "Harshil";
       $manageoutofstockId     = $this->getRequest()->getParam('id');
        var_dump ($manageoutofstockId);
        $manageoutofstockModel  = Mage::getModel('manageoutofstock/manageoutofstock')->load($manageoutofstockId);
        var_dump ($manageoutofstockId);
        if ($manageoutofstockModel->getId() || $manageoutofstockId == 0) {

            Mage::register('manageoutofstock_data', $manageoutofstockModel);

            $this->loadLayout();
            $this->_setActiveMenu('manageoutofstock/items');

            $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('manageoutofstock/adminhtml_manageoutofstock_edit'))
                 ->_addLeft($this->getLayout()->createBlock('manageoutofstock/adminhtml_manageoutofstock_edit_tabs'));

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

And here is my Form.php

<?php
class Vrinsoft_Manageoutofstock_Block_Adminhtml_Manageoutofstock_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{

    $form = new Varien_Data_Form();
    $this->setForm($form);
$fieldset = $form->addFieldset('manageoutofstock_form', array('legend'=>Mage::helper('manageoutofstock')->__('Item information')));

    $fieldset->addField('product_id', 'text', array(
        'label' => Mage::helper('manageoutofstock')->__('Product Id'),
        'class' => 'required-entry',
        'required' => true,
        'name' => 'product_id',
    ));

    $fieldset->addField('email', 'text', array(
        'name' => 'email',
        'label' => Mage::helper('manageoutofstock')->__('Email ID'),
        'title' => Mage::helper('manageoutofstock')->__('Email ID'),
        //'style' => 'width:98%; height:400px;',
        'wysiwyg' => false,
        'required' => true,
    ));

    $fieldset->addField('status', 'select', array(
        'label' => Mage::helper('manageoutofstock')->__('Status'),
        'name' => 'status',
        'values' => array(
            array(
            'value' => 1,
            'label' => Mage::helper('manageoutofstock')->__('Active'),
            ),
            array(
            'value' => 0,
            'label' => Mage::helper('manageoutofstock')->__('Inactive'),
            ),
        ),
    ));




 if ( Mage::getSingleton('adminhtml/session')->getManageoutofstockData() )
{
$form->setValues(Mage::getSingleton('adminhtml/session')->getManageoutofstockData());
Mage::getSingleton('adminhtml/session')->setManageoutofstockData(null);
} elseif ( Mage::registry('manageoutofstock_data') ) {
$form->setValues(Mage::registry('manageoutofstock_data')->getData());
} 
return parent::_prepareForm();
}
}

Can any one help me ? Any kind of help will appreciate.

1 Answer 1

1

Change return parent::_prepareForm(); to return $this; in Form.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.