0
 $fieldset->addField('image', 'image', array(
          'label'     => Mage::helper('featuredsalons')->__('Image'),
          'required'  => true,

        //'multiple'  => true, 
        //'multiple'  => 'multiple', 
          'name'      => 'image',
          'after_element_html' => '<p class="note"><span>Image Dimension: </span></p>'
      ));

I have tried above mentiion to allow multple images , but failed.

1
  • If it is enough, you can just add multiple file input fields. Is multiple limited? Or is multiple 0+? Aug 27, 2013 at 19:20

3 Answers 3

1

The only "multiple image" widget available in a default Magento install is the EAV Attribute type gallery.

I'm pretty sure however that you'll need to implement the same Adminhtml_Widgets in order to use it on something other than a product (like a custom EAV Entity with a custom form).

If you just need a custom form (without a custom entity or for a custom Flat entity) you may be better off creating your own Controllers and implementing SWF Upload yourself using your own logic/structures.

1

You should change this function getElementHtml in this file lib\Varien\Data\Form\Element\Abstract.php like this:

public function getElementHtml(){
            if($this->getType()=='file' && $this->getMultiple())
                $_multiple = ' multiple';
            $html = '<input id="'.$this->getHtmlId().'" name="'.$this->getName()
                 .'" value="'.$this->getEscapedValue().'" '.$this->serialize($this->getHtmlAttributes()).$_multiple.'/>'."\n";
            $html.= $this->getAfterElementHtml();
            return $html;
    }

after that you able to upload multiple file with your file field

Example: In form file

 $fieldset->addField('optionimage', 'file', array(
                            'label'     => Mage::helper('option_module')->__('Option Image'),
                            'required'  => false,
                            'name'      => 'optionimage[]',
                            'multiple'=>true,
                            'multiple'=>'multiple'
            ));

and in your controller

1
0

You should change your 'name' value and add '[]', finally it should looks like this:

$fieldset->addField('image', 'image', array(
      'label'     => Mage::helper('featuredsalons')->__('Image'),
      'required'  => true,
      'multiple'  => 'multiple', 
      'name'      => 'image[]',
      'after_element_html' => '<p class="note"><span>Image Dimension: </span></p>'
  ));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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