-1

I added buttons for delete and drag but not working, my code in the view:

<?= $form->field($model, 'imageFiles[]')->widget(FileInput::classname(), [

   'options' => ['multiple' => true, 'accept' => 'image/*', 
     'id'=>'inputFile'],
   'pluginOptions' => [
   'rtl'=>'true',
   'fileActionSettings'=>['showZoom'=>true, 'showRemove' =>true, 
   'showDrag'=>true],
   'previewFileType' => 'image',
   'maxFileCount' => 4,
   'showUpload' => false,
   ]
]);

Where are i making mistakes?

Matthew Verstraete
  • 6,335
  • 22
  • 67
  • 123
MHF
  • 211
  • 2
  • 14

1 Answers1

1

When using FORM submission mode (without uploadUrl). in this scenario you cannot REMOVE preview thumbnails before they are uploaded - ONE by ONE (you can only clear all - this is a native HTML FILE input limitation as one cannot edit the files in the input). in this case we must add uploadUrl:

 <?= $form->field($model, 'imageFiles[]')->widget(FileInput::classname(), [

      'options' => ['multiple' => true, 'accept' => 'image/*', 
       'id'=>'inputFile'],
       'pluginOptions' => [
       'uploadUrl' => '/site/index',
       'rtl'=>'true',
       'fileActionSettings'=>['showZoom'=>true, 'showRemove' =>true, 
       'showDrag'=>true],
       'previewFileType' => 'image',
       'maxFileCount' => 4,
       'showUpload' => false,
       ]
    ]);

This is ajax submission mode with uploadUrl.

MHF
  • 211
  • 2
  • 14