'capture' => '',
'class' => 'file',
'required' => true,
- ],
+ ],
'pluginOptions' => [
-// 'previewFileType' => ['jpg','png'],
-// 'allowedFileExtensions'=>['jpg','png'],
- 'showPreview' => false,
- 'showCaption' => true,
- 'showRemove' => true,
- 'showUpload' => false,
- //'uploadClass' => 'hide',
-// 'initialPreview'=> $initalImages,
- 'overwriteInitial' => true,
-
-// 'initialPreviewAsData'=>true,
- //initialPreviewAsData: false,
-// 'bsColCssPrefixes'=>3,
- // 'uploadUrl' => Url::to(['/site/image-manager-upload']),
+ 'showPreview' => true,
+ 'showCaption' => true, // ✅ Должно быть true
+ 'initialCaption' => '55656',
+ 'initialPreview' => '809',
+// 'initialPreviewConfig' => function($data) {
+// if (!$data || !isset($data['id'])) return [];
+// $file = Files::findOne([
+// 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
+// 'entity_id' => $data['id']
+// ]);
+// return $file ? [[
+// 'caption' => basename($file->url), // ✅ Обязательно!
+// 'type' => 'video',
+// 'size' => @filesize(Yii::getAlias('@webroot') . $file->url),
+// ]] : [];
+// },
'browseIcon' => '+',
'cancelIcon' => 'x',
'removeIcon' => '-',
]
],
[
- 'name' => 'video',
- 'title' => 'Видео',
- 'type' => 'fileInput',
- 'options' => [
- 'options' => [
- 'accept' => 'video/*',
- 'multiple' => false,
- ],
- ],
+ 'name' => 'videoFiles',
+ 'title' => 'Видео: mp4, mov, avi',
+ 'type' => FileInput::className(),
'value' => function ($data) {
- if (empty($data['id'])) return null;
+ if (!$data || !isset($data['id'])) return null;
$file = Files::findOne([
'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
'entity_id' => $data['id']
]);
- return $file ? basename($file->url) : null;
- }
+ if (!$file) return null;
+
+ $initialPreview = [$file->url];
+ $initialPreviewConfig = [[
+ 'type' => 'video',
+ 'caption' => basename($file->url),
+ 'url' => Url::to(['delete-video', 'id' => $data['id']])
+ ]];
+
+ return [
+ 'caption' => basename($file->url),
+ 'url' => $file->url,
+ 'initialPreview' => $initialPreview,
+ 'initialPreviewConfig' => $initialPreviewConfig
+ ];
+ },
+ 'options' => [
+ 'options' => [
+ 'multiple' => false,
+ 'accept' => 'video/*',
+ 'name' => 'video_name'
+ ],
+ 'pluginOptions' => [
+ 'showPreview' => true,
+ 'showCaption' => true,
+ 'showRemove' => true,
+ 'showUpload' => true,
+ 'previewFileType' => 'video',
+ 'allowedFileTypes' => ['video'],
+ 'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
+ 'maxFileSize' => 10240,
+ ],
+ ],
],
[
'name' => 'comment',
'title' => 'Комментарий',
],
-
],
'addButtonPosition' => MultipleInput::POS_FOOTER, // show add button in the header
])->label(false); ?>