I'm trying to display product thumbnails in my custom module admin form. But for some reason no thumbnail is showing up.
When I use the code below, it only shows the browse button with no thumbnail, like in the image below.
protected function _prepareForm()
{
$model = Mage::registry('cpstest_productcomment');
$form = new Varien_Data_Form(array(
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
'method' => 'post',
'enctype' => 'multipart/form-data'
));
$fieldset->addField('image', 'image', array(
'label' => Mage::helper('catalog')->__('Image'),
'required' => false,
'name' => 'image',
));
}
And when I use this code, I get an error:
Fatal error: Call to a member function getData() on null in ...\app\code\core\Mage\Catalog\Helper\Image.php on line
$fieldset->addField('image', 'image', array(
'label' => Mage::helper('catalog')->__('Image'),
'required' => false, // Make true if required field
'name' => 'image',
'value' => Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(100)
));