Here, I would like to upload multiple image in admin panel grid form in magento. I create images upload in admin panel grid form.
Here I attached my image upload coding.
[....]
$fieldset->addField('image', 'image', array(
'name' => 'image',
'label' => Mage::helper('magentostudy_design')->__('design Image'),
'title' => Mage::helper('magentostudy_design')->__('design Image'),
'required' => true,
'disabled' => $isElementDisabled
));
[....]
when i change multiple upload image by using this argument. 'multiple'=> 'multiple'
Here my code:
[....]
$fieldset->addField('image', 'image', array(
'name' => 'image',
'multiple' => 'multiple',
'mulitple' => true,
'label' => Mage::helper('magentostudy_design')->__('design Image'),
'title' => Mage::helper('magentostudy_design')->__('design Image'),
'required' => true,
'disabled' => $isElementDisabled
));
[....]
And also i put name value as array[] just like this 'name' => 'image[]',
.
Nope, i am not getting any result, still single image will be uploaded. How to create multiple image upload concept in magento. Can any one Help me to solve this problem.Please guide me.
Best Answer
Continuing my comment, here is how you can achieve what you need.
You need to create your custom renderer for the image field. For this create this class in your module:
Now at the top of your
_prepareForm
(where you add your fields) add this line before adding any field:Or if you want to be "politically correct" add it this way:
This will tell Magento that in your current fieldset, all the fields with type
image
should be rendered by your own class.Now you can add your field like similar to how you did it:
That's it.
Don't forget to replace the placeholders (
[Module]
and others) with your values.[EDIT]
This is basically the way to override/add any input type you want. Create your own class that should extend the original input class (or
Varien_Data_Form_Element_Abstract
if you add a new one) and declare it at the top of_prepareForm