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.