Yii2 - css of widgets are not working

968 views Asked by At

I am working with https://github.com/2amigos/yii2-file-upload-widget widget of Yii2. I used this widget in Backend (advanced template) and its working. Its js and css are automatically added to the html. But when I use this in Frontend, only js are added to the html, but not css. Strange thing.

use dosamigos\fileupload\FileUploadUI;

<?= FileUploadUI::widget([
    'model' => $mdlproductimage,
    'attribute' => 'image',
    'url' => ['product/image-upload', 'id' => $mdlproductimage->primgid],
    'gallery' => false,
    'fieldOptions' => [
            'accept' => 'image/*'
    ],
    'clientOptions' => [
            'maxFileSize' => 2000000
    ],
    // ...
    'clientEvents' => [
            'fileuploaddone' => 'function(e, data) {
                                    console.log(e);
                                    console.log(data);
                                }',
            'fileuploadfail' => 'function(e, data) {
                                    console.log(e);
                                    console.log(data);
                                }',
    ],
]);
?>

I know it is not the issue of Frontend/Backend. It may be any option which changed and I don't know about about it.

Edit 1: HTML Code

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Homepage</title>
<meta name="description" content="Homepage">
<script type="text/javascript" src="./js/jquery-1.11.1.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

<link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="./css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="./css/bootstrap.offcanvas.min.css" />
<link rel="stylesheet" type="text/css" href="./css/style.css" />
<link rel="stylesheet" type="text/css" href="./css/normalize.css" />
<link rel="stylesheet" type="text/css" href="./css/off_canvas_nav.css" />
<link rel="stylesheet" type="text/css" href="./css/offCanvas.css" />
<link rel="stylesheet" type="text/css" href="./css/custom.css" />
<!--[if lt IE 9]>
    <script src="./js/html5shiv.js"></script>
    <script src="./js/respond.min.js"></script>
    <![endif]-->
</head>

Anyone can help?

1

There are 1 answers

0
Bizley On BEST ANSWER

You are missing

<?php $this->head() ?>

in the layout <head> section. Assets registered to be placed in the head part of HTML can not be rendered.