0

I've a grid view already done, but I need to put it into a fieldset, how can I implement this?

This is my Grid.php

class Ns_Thorleif_Block_Adminhtml_Commerciaux_Grid extends Mage_Adminhtml_Block_Widget_Grid
{

    public function __construct()
    {
        parent::__construct();
        $this->setId('commerciaux_grid');
        $this->setDefaultSort('id');
        $this->setDefaultDir('ASC');
        $this->setSaveParametersInSession(true);
    }

    public function _prepareCollection()
    {
        $collection = Mage::getModel('thorleif/commerciaux')->getCollection();
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

    public function _prepareColumns()
    {
        $this->addColumn('id',
            array(
                'header' => 'ID',
                'align' => 'left',
                'width' => '10%',
                'index' => 'id'
            )
        );
        $this->addColumn('name',
            array(
                'header' => 'Category Name',
                'align' => 'left',
                'index' => 'name'
            )
        );
        $this->addColumn('route',
            array(
                'header' => 'Route',
                'align' => 'left',
                'index' => 'route'
            )
        );
        $this->addColumn('cat2',
            array(
                'header' => 'Category2',
                'align' => 'left',
                'index' => 'category2'
            )
        );
        $this->addColumn('tax',
            array(
                'header' => 'Tax',
                'align' => 'left',
                'index' => 'tax'
            )
        );
        $this->addColumn('action',
            array(
                'header' => 'Action',
                'align' => 'left',
                'index' => 'action'
            )
        );
        return parent::_prepareColumns();
    }
}

Doing some test to have a forms a put this code in the same file without grid

class Ns_Thorleif_Block_Adminhtml_Commerciaux_Grid extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
{
    $form = new Varien_Data_Form();
    $this->setForm($form);

    // section one
    $fieldset = $form->addFieldset('commerciaux_form', array('legend' => 'Configuration account'));

    $fieldset->addField('country', 'select', array(
        'label' => 'Country',
        'class' => 'required-entry',
        'values' => array('1' => 'Mexico','2' => 'Colombia', '3' => 'Argentina', '4' => 'Peru', '5' => 'Ecuador', '6' => 'Panama', '7' => 'Chile', '8' => 'Venezuela' ),
        'required' => true,
        'name' => 'country'
    ));

    $fieldset->addField('email', 'text', array(
        'label' => 'Email address',
        'class' => 'required-entry',
        'required' => true,
        'name' => 'email'
    ));

    $fieldset->addField('key', 'text', array(
        'label' => 'Api key',
        'class' => 'required-entry',
        'required' => true,
        'name' => 'key'
    ));

    $fieldset->addField('tax', 'select', array(
        'label' => 'Tax',
        'class' => 'required-entry',
        'required' => true,
        'name' => 'tax'
    ));

    $fieldset->addField('time', 'text', array(
        'label' => 'Supply time',
        'class' => 'required-entry',
        'required' => true,
        'name' => 'time'
    ));

    $fieldset->addField('warranty', 'textarea', array(
        'label' => 'Warranty',
        'class' => 'required-entry',
        'required' => true,
        'name' => 'warranty'
    ));

    // section two
    $fieldset = $form->addFieldset('commerciaux_form_2', array('legend' => 'Variations Mapping'));

    $fieldset->addField('variation', 'text', array(
        'label' => 'You should match size if you want to upload products to Fashion subcategory',
        'class' => 'required-entry',
        'required' => true,
        'name' => 'variation'
    ));

    // section three
    $fieldset = $form->addFieldset('commerciaux_form_3', array('legend' => 'Category Mapping'));
    $fieldset->addField('category', 'text', array(
        'label' => 'Category',
        'class' => 'required-entry',
        'required' => true,
        'name' => 'category'
    ));


    if ($commerciauxData = Mage::registry('commerciaux_data')) {
        $form->setValues($commerciauxData->getData());
    }
    return parent::_prepareForm();
}
}

so the idea I want to implement it having those forms ( two fieldset) and in the same page in third fieldset the grid. enter image description here

5
  • please provide more information with your code. Commented May 24, 2017 at 16:40
  • form is working properly at your end?? Commented May 24, 2017 at 16:58
  • you want three tabs on from page? Commented May 24, 2017 at 17:00
  • @Gopal, yes I've added a picture to have an idea regarding my request I want to implement. I'm new in magento so I'm trying to understand the relation and level between each folder(Model, Helper, Controller, Block).
    – javaTodev
    Commented May 24, 2017 at 17:14
  • Any suggestion please?
    – javaTodev
    Commented May 25, 2017 at 15:14

1 Answer 1

0

This post help to implement it. you have to create a new custom field type and render the grid on it.

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.