I'm working on a module in magento admin where I would like to show the scope selector
as in manage products, manage categories, system configuration for my grid edit form.
![screenshot][1]
Can anyone help me how could I add that and store values in database specific to the scope selected
?
Update
saveAction()
from adminhtml controller
public function saveAction() {
if ($data = $this->getRequest()->getPost()) {
if (isset($_FILES['smalllogo']['name']) && $_FILES['smalllogo']['name'] != '') {
try {
/* Starting upload */
$uploader = new Varien_File_Uploader('smalllogo');
// Any extention would work
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->setAllowRenameFiles(false);
// Set the file upload mode
// false -> get the file directly in the specified folder
// true -> get the file in the product like folders
// (file.jpg will go in something like /media/f/i/file.jpg)
$uploader->setFilesDispersion(false);
// We set media as the upload dir
$path = Mage::getBaseDir('media') . DS;
$logo = $uploader->save($path, $_FILES['smalllogo']['name']);
} catch (Exception $e) {
}
// $mediaPath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
$data['smalllogo'] = $logo['file']; //$_FILES['smalllogo']['name']; //$mediaPath . $_FILES['smalllogo']['name'];
} else if (isset($data['smalllogo']['delete']) && $data['smalllogo']['delete'] == 1) {
unlink(Mage::getBaseDir('media') . DS . $data['smalllogo']['value']);
$data['smalllogo'] = '';
} else {
unset($data['smalllogo']);
}
if (isset($_FILES['banner']['name']) && $_FILES['banner']['name'] != '') {
try {
/* Starting upload */
$uploader = new Varien_File_Uploader('banner');
// Any extention would work
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->setAllowRenameFiles(false);
// Set the file upload mode
// false -> get the file directly in the specified folder
// true -> get the file in the product like folders
// (file.jpg will go in something like /media/f/i/file.jpg)
$uploader->setFilesDispersion(false);
$path = Mage::getBaseDir('media') . DS;
$banner = $uploader->save($path, $_FILES['banner']['name']);
} catch (Exception $e) {
}
// $mediaPath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
$data['banner'] = $banner['file']; //$_FILES['banner']['name']; //$mediaPath . $_FILES['banner']['name'];
} else if (isset($data['banner']['delete']) && $data['banner']['delete'] == 1) {
unlink(Mage::getBaseDir('media') . DS . $data['banner']['value']);
$data['banner'] = '';
} else {
unset($data['banner']);
}
$model = Mage::getModel('designer/designer');
$model->setData($data)
->setId($this->getRequest()->getParam('id'));
try {
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
$model->setCreatedTime(now())
->setUpdateTime(now());
} else {
$model->setUpdateTime(now());
}
$model->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('designer')->__('Designer was successfully saved'));
Mage::getSingleton('adminhtml/session')->setFormData(false);
if ($this->getRequest()->getParam('back')) {
$this->_redirect('*/*/edit', array('id' => $model->getId()));
return;
}
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setFormData($data);
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
return;
}
}
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('designer')->__('Unable to find designer to save'));
$this->_redirect('*/*/');
}