0

Hi I am following the solution provided here but the multiple images are not uploading in the form.

I click on the browse button in the form, new window opens for selecting the images and when I tried to select more than one images from there, it is not happening. It only select one image at a time. How can I select multiple option from here.

what should I do to do this correctly.

Here is my image form

<?php
class Vertax_Blog_Block_Adminhtml_Article_Edit_Tab_Image extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{

   $form = new Varien_Data_Form();
   $this->setForm($form);
   $fieldset = $form->addFieldset('image_form',
                                   array('legend'=>'image'));
$fieldset->addType('image', Mage::getConfig()->getBlockClassName('blog/adminhtml_article_helper_image'));
//$fieldset->addType('image', 'Vertax_Blog_Block_Adminhtml_Article_Helper_Image');

$fieldset->addField('image', 'file', array(
        'label'     => 'Image',
        'required'  =>  false,
        'name'      => 'image[]',
    'multiple'  => 'multiple',
    'mulitple'  =>  true,
    ));

if (Mage::getSingleton('adminhtml/session')->getBlogPostData()) {
        $form->setValues(Mage::getSingleton('adminhtml/session')->getBlogPostData());
        Mage::getSingleton('adminhtml/session')->setBlogPostData(null);
    } elseif (Mage::registry('article_data')) {
        $form->setValues(Mage::registry('article_data')->getData());
    }
    return parent::_prepareForm();
}
}
?>
  • possible duplicate of How to upload multiple image in admin panel grid form? – Marius Feb 26 '14 at 13:05
  • @Marius I am following the solution provided here but its not working. – Waseem Feb 26 '14 at 13:07
  • Try with $fieldset->addField('image', 'image', array( instead of $fieldset->addField('image', 'file', array( – Marius Feb 26 '14 at 14:32
  • @Marius thanks for this. I figured that out. Its my bad, I didn't notice that. Thanks once again. – Waseem Feb 27 '14 at 4:36
1

Just so this question would have an answer...
Based on the comments, the issue is the field type:

$fieldset->addField('image', 'file', array(...))

should be

$fieldset->addField('image', 'image', array(...))

More explanations on how to add a multiple image upload can be found in this answer

  • i used this for selecting multiple images and it works but still images are not uploading the code breaks on $uploader = new Varien_File_Uploader('image') line. I dont know how can I do it properly. – Waseem Feb 28 '14 at 9:19
  • @Waseem. This seams like a totally different question. Ask a new one and post your controller code in there. – Marius Feb 28 '14 at 9:20
  • Thanks I asked the question here take a look. – Waseem Feb 28 '14 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.