From: marina Date: Tue, 27 May 2025 08:32:30 +0000 (+0300) Subject: ERP-417 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=fa0175888bdc45a2cda145ad93c7ad4d07ba1103;p=erp24_rep%2Fyii-erp24%2F.git ERP-417 --- diff --git a/erp24/views/write_offs_erp/_form.php b/erp24/views/write_offs_erp/_form.php index 3d6d8f5d..0c1c2a94 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -258,58 +258,51 @@ JS 'name' => 'videoFiles', 'title' => 'Видео: mp4, mov, avi', 'type' => FileInput::className(), - 'value' => function ($model) { + 'options' => function ($row, $index) use ($model) { + $videoUrl = null; + + if (!empty($model->id)) { + $videoUrl = Files::find() + ->select('url') + ->where([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $model->id + ]) + ->scalar(); + } - var_dump($model['id']); - die(); - }, - 'options' => [ - 'options' => [ - 'multiple' => false, - 'accept' => 'video/*', - 'name' => 'video_name', - 'capture' => '', - 'class' => 'videos' - ], - 'pluginOptions' => [ - 'showPreview' => false, - 'showCaption' => true, - 'showRemove' => true, - 'showUpload' => false, - 'overwriteInitial' => true, - 'browseIcon' => '+', - 'cancelIcon' => 'x', - 'removeIcon' => '-', - 'buttonLabelClass' => 'hidden', - 'fileActionSettings' => ['showUpload' => false], - 'multiple' => false, - 'previewFileType' => 'video', - 'allowedFileExtensions' => ['mp4', 'mov', 'avi'], - 'initialPreview' => isset($model->id) ? [ - Files::find() - ->select('url') - ->where([ - 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, - 'entity_id' => $model->id - ]) - ->scalar() - ] : [], - 'initialPreviewAsData' => true, - 'initialPreviewConfig' => isset($model->id) ? [[ - 'type' => 'video', - 'caption' => basename( - Files::find() - ->select('url') - ->where([ - 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, - 'entity_id' => $model->id - ]) - ->scalar() - ), - 'url' => Url::to(['delete-video', 'id' => $model->id]), - ]] : [], - ] - ] + return [ + 'options' => [ + 'multiple' => false, + 'accept' => 'video/*', + 'name' => 'video_name', + 'capture' => '', + 'class' => 'videos' + ], + 'pluginOptions' => [ + 'showPreview' => false, + 'showCaption' => true, + 'showRemove' => true, + 'showUpload' => false, + 'overwriteInitial' => true, + 'browseIcon' => '+', + 'cancelIcon' => 'x', + 'removeIcon' => '-', + 'buttonLabelClass' => 'hidden', + 'fileActionSettings' => ['showUpload' => false], + 'multiple' => false, + 'previewFileType' => 'video', + 'allowedFileExtensions' => ['mp4', 'mov', 'avi'], + 'initialPreview' => $videoUrl ? [$videoUrl] : [], + 'initialPreviewAsData' => true, + 'initialPreviewConfig' => $videoUrl ? [[ + 'type' => 'video', + 'caption' => basename($videoUrl), + 'url' => Url::to(['delete-video', 'id' => $model->id]), + ]] : [], + ] + ]; + } ], [ 'name' => 'comment',