3

I have created a custom extension just like a customer module and I want backend just like a customer.

My extension has two tables and two models. My modules are:

Mage::getModel('custommod/reg') - just like Mage::getModel('customer/customer'), reg saves data of registration

Mage::getModel('custommod/personal') - just like Mage::getModel('customer/address'), //personal data of a reg records. Please check the image below: enter image description here Now I am facing the problem to show the data and edit . In Magento customer admin section, Customer edit position has multiple tabs: Account information, Address etc.

Here, Account information tab saves data in customer/customer and Address information tab saves data in customer/address.

I like this type of section.

Cipryst
  • 223
  • 1
  • 13
Amit Bera
  • 7,581
  • 7
  • 31
  • 57
  • Have a look http://stackoverflow.com/questions/14145237/magento-tabbed-backend-like-catalog-product-for-custom-entity/14151654#14151654 – Amit Kumar Feb 01 '14 at 08:32
  • Amit,but issue when i want to show the the data ,when i edit the tab...second data will save into other module.... – Amit Bera Feb 01 '14 at 09:52
  • In saveAction you can save the data to whichever table you want.. you must be getting all post data.. – Pankaj Feb 17 '14 at 10:08
  • ok,thanks for your reply.....,I have already done it – Amit Bera Feb 17 '14 at 10:15
  • 1
    If you have already done that then why you have not added your code...means how you done and all the stuff..that can help other people who visit this post and also if they like your answer you can get some upvotes too. – Kingshuk Deb Feb 24 '14 at 04:20

1 Answers1

7

After a long time work i have done it ,Here the solution The tabs.php show left panel

<?php

class Amit_Vendor_Block_Adminhtml_List_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('vendor_tabs');
        $this->setDestElementId('edit_form');
        $this->setTitle(Mage::helper('vendor')->__('Manage Vendor'));
    }

    protected function _beforeToHtml()
    {
        $this->addTab('form_section', array(
            'label' => Mage::helper('vendor')->__('General Information'),
            'title' => Mage::helper('vendor')->__('General Information'),
            'content' => $this->getLayout()->createBlock('vendor/adminhtml_list_edit_tab_form')->toHtml(),
        ));



    $this->addTab('vendor_details',array(
                'label'=>Mage::helper('vendor')->__('Vendor Store  Details'),
                'title'=>Mage::helper('vendor')->__('Vendor Store  Details'),
                'content'=>$this->getLayout()->createBlock('vendor/adminhtml_list_edit_tab_storedetails')->toHtml(),

    ));
        return parent::_beforeToHtml();
    }
}

after the form.php

<?php

class Amit_Vendor_Block_Adminhtml_List_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
    {
        $vendor = Mage::registry('vendor_data');
        $form = new Varien_Data_Form(); 
        $fieldset = $form->addFieldset('vendor_form', array(
            'legend' => Mage::helper('vendor')->__('Vendor Registration')
        ));

        $fieldset->addField('name', 'text', array(
            'name' => 'name',
            'label' => Mage::helper('vendor')->__('Name'),
            'required' => true,
        ));


        $fieldset->addField('email', 'text', array(
            'name'    => 'email',
            'label'   => Mage::helper('vendor')->__('Email'),
            'required' => true,

        ));
         $fieldset->addField('user_name', 'text', array(
            'name'    => 'user_name',
            'label'   => Mage::helper('vendor')->__('User name'),
            'required' => true,

        ));




        $fieldset->addField('password', 'password', array(
            'name'     => 'password',
            'class' => 'required-entry',
            'label'    => Mage::helper('vendor')->__('Password'),
            'required' => true,
        ));

        $this->setForm($form);
        $form->setValues($vendor->getData());

        return parent::_prepareForm();
    }

    public function filter($value)
    {
        return number_format($value, 2);
    }
}

Second form Storedetails.php

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

        $vendorStore = Mage::registry('vendor_store_details');// new registry for different module
        $form = new Varien_Data_Form(); 
        //$form->setFieldNameSuffix('vendor_store');

        $fieldset = $form->addFieldset('vendor_form', array(
        'legend' => Mage::helper('vendor')->__('Vendor deatsilsn')
        ));

        $fieldset->addField('alternative_email','text',array(
            'name' =>'alternative_email',
            'label' => Mage::helper('vendor')->__('Alternative Email'),
            'required'=> false
        ));
        $fieldset->addField('shopname','text',array(
            'name' =>'shopname',
            'label' => Mage::helper('vendor')->__('Shop Name'),
            'required'=> true,
            'class'     => 'required-entry',
        ));
        $fieldset->addField('company', 'text', array(
        'name' => 'company',
        'label' => Mage::helper('vendor')->__('Company'),
        'required' => true,
         'class'     => 'required-entry',
        ));
        $fieldset->addField('street','text',array(
            'name' =>'vendor_details[street]',
            'label' => Mage::helper('vendor')->__('Street Address'),
            'required'=> false
        ));


        $this->setForm($form);
        $form->addValues($vendorStore->getData());
        return parent::_prepareForm();

        }


}
Amit Bera
  • 7,581
  • 7
  • 31
  • 57