]
],
[
- 'name' => 'videoFiles',
- 'title' => 'Видео: mp4, mov, avi',
- 'type' => FileInput::className(),
- 'value' => function ($row) {
- if (!isset($row['id'])) return null;
-
- $file = Files::findOne([
+ 'name' => 'videoFiles',
+ 'title' => 'Видео: mp4, mov, avi',
+ 'type' => FileInput::class,
+ 'options' => [
+ 'options' => [
+ 'multiple' => false,
+ 'accept' => 'video/*',
+ 'name' => 'video_name',
+ ],
+ 'pluginOptions' => [
+ 'showPreview' => true,
+ 'showCaption' => true,
+ 'showRemove' => true,
+ 'showUpload' => false,
+ 'previewFileType' => 'video',
+ 'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
+ 'initialPreview' => isset($model->id) ? [ // или $row['id'], если это в цикле
+ Files::find()
+ ->select('url')
+ ->where([
+ 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
+ 'entity_id' => $model->id // или $row['id']
+ ])
+ ->scalar()
+ ] : [],
+ 'initialPreviewAsData' => true,
+ 'initialPreviewConfig' => isset($model->id) ? [[
+ 'type' => 'video',
+ 'caption' => basename(
+ Files::find()
+ ->select('url')
+ ->where([
'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
- 'entity_id' => $row['id']
- ]);
-
- return $file ? $file->url : null;
- },
- 'options' => [
- 'options' => [
- 'multiple' => false,
- 'accept' => 'video/*',
- 'name' => 'video_name',
- 'class' => 'file'
- ],
- 'pluginOptions' => [
- 'showPreview' => false,
- 'showCaption' => true,
- 'showRemove' => true,
- 'showUpload' => false,
- 'browseIcon' => '+',
- 'cancelIcon' => 'x',
- 'removeIcon' => '-',
- 'buttonLabelClass' => 'hidden',
- 'fileActionSettings' => ['showUpload' => false],
- 'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
- 'maxFileCount' => 1,
- 'overwriteInitial' => true,
- ],
- ]
- ],
+ 'entity_id' => $model->id
+ ])
+ ->scalar()
+ ),
+ 'url' => Url::to(['delete-video', 'id' => $model->id]),
+ ]] : [],
+ ]
+ ]
+],
[
'name' => 'comment',
'type' => 'textInput',