سؤال

لدي سؤال أنا نشر هو سيلي وطلب عدة مرات في هذا المنتدى ولكن لا إجابة الجواب أرسلت من قبل الآخرين تم حل مشكلتي.

سؤالي هو لدي فيلدسيت من الملفات وتحتاج إلى تحميل الصور مع متعددة لذلك كنت قد استخدمت

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

ولكن أنا فشلت في إضافة متعددة الحقل أعلاه

هل كانت مفيدة؟

المحلول

افتراضيا لا يمكنك القيام بذلك.
شرحت هنا لماذا ليس من الممكن من خارج منطقة الجزاء ، وكيف يمكنك ان تجعل من العمل.
التفسير هو لمدخلات الصورة لكنه يعمل نفسه لحقول الصورة.
والفكرة هي أن" متعددة " ليست سمة مسموح بها لمدخلات الملف.
تحتاج إلى إنشاء عارض الإدخال الذي تم ربحه والذي يمتد Varien_Data_Form_Element_File (أو Image إذا كنت في حاجة إليها للصور) وجعلها تسمح multiple كما السمة.

لذلك يمكن أن يبدو العارض الخاص بك كما يلي

<?php 
class [Namespace]_[Module]_Block_Adminhtml_[Entity]_Helper_Image extends Varien_Data_Form_Element_Image //or _File if you are not uploading images
{
    //make your renderer allow "multiple" attribute
    public function getHtmlAttributes(){
        return array_merge(parent::getHtmlAttributes(), array('multiple'));
    }
}

في نموذج التحرير الخاص بك أضف هذا:

$fieldset->addType('image', '[Namespace]_[Module]_Block_Adminhtml_[Entity]_Helper_Image');

أو إذا كنت لا تريد تحميل الصور فقط

$fieldset->addType('file', '[Namespace]_[Module]_Block_Adminhtml_[Entity]_Helper_File');

ثم أضف مجالك مثل هذا:

$fieldset->addField(
    'id_here', 
    'image',  //or file
    array( 
            'name'      => 'image[]', //declare this as array. Otherwise only one image will be uploaded
            'multiple'  => 'multiple', //declare input as 'multiple'
            'label'     => Mage::helper('helper_alias')->__('Image'),
            'title'     => Mage::helper('helper_alias')->__('Image'),
            'required'  => true,
        )
 );
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top