I am using kartik file input widget in a yii2 project.
http://demos.krajee.com/widget-details/fileinput
Everything is fine until the update page is accessed where the already uploaded images for a particular post are displayed using the 'initialPreview' option. The preview works, but when the form is submitted, the file input is empty and the form won't validate. Poster Image (256x376) cannot be blank.
<?php
echo $form->field($model, 'posterImage')->widget(FileInput::classname(), [
'options' => [
'multiple' => true,
'accept' => 'image/*',
],
'pluginOptions' => [
'maxImageWidth' => 265,
'maxImageHeight' => 376,
'minImageWidth' => 265,
'minImageHeight' => 376,
'previewFileType' => 'image',
'allowedFileExtensions' => [
'jpg', 'jpeg'
],
'showUpload' => false,
'maxFileSize' => 200,
'maxFileCount' => 1,
'initialPreview' => [
$model->posterImage ? Html::img($model->posterImage, ['width' => '100%']) : NULL,
],
'initialPreviewConfig' => [
['url' => $model->posterImage],
],
'initialPreviewAsData' => false,
'overwriteInitial' => true,
]
]);
?>
modelclass ? - Touqeer ShafiskipOnEmptyon validations rules yiiframework.com/doc-2.0/guide-input-file-upload.html - Touqeer Shafi