$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.
-
If it is enough, you can just add multiple file input fields. Is multiple limited? Or is multiple 0+?Fabian Blechschmidt– Fabian Blechschmidt2013年08月27日 19:20:19 +00:00Commented Aug 27, 2013 at 19:20
3 Answers 3
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.
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
-
Never edit core files!Fabian Blechschmidt– Fabian Blechschmidt2015年06月25日 10:54:25 +00:00Commented Jun 25, 2015 at 10:54
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>'
));