I have a custom module, through which I can upload multiple images from admin. Along with images, I have text, drop-down form fields in my module. Now I can upload all images to media folder of Magento and can store all form field information in the database. Now when editing my stored item from the grid page, I need to show all the images that correspond to the saved item in my module. How can achieve this? I think the code should come under editAction() in the controller. Any help or hint is highly appreciated. Thanks in advance.
My editAction() is given below. It displays already set form fields except for images while editing the item from the grid page.
<?php
public function editAction()
{
$bannerId = $this->getRequest()->getParam('id');
$bannerModel = Mage::getModel('banner/banner')->load($bannerId);
if ($bannerModel->getId() || $bannerId == 0)
{
Mage::register('banner_data', $bannerModel);
$this->loadLayout();
$this->_setActiveMenu('banner/items');
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Banner Manager'), Mage::helper('adminhtml')
->__('Banner Manager'));
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Banner Description'),
Mage::helper('adminhtml')->__('Banner Description'));
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$this->_addContent($this->getLayout()->createBlock('banner/adminhtml_banner_edit'))
->_addLeft($this->getLayout()->createBlock('banner/adminhtml_banner_edit_tabs'));
$this->renderLayout();
}
else
{
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('banner')->__('Banner does not exist'));
$this->_redirect('*/*/');
}
}
EDIT Kindly note that I have two tabs for my module. Image uploading facility is provided in the second tab. I have used a phtml file for constructing that tab. So image upload field is provided thereby using <.input type="file" /> element. I need to display the uploaded images in this tab itself. So in effect, I need to add code in my phtml file in order to display these images.