Reputation: 672
I've installed bootstrap-datepicker using composer on my Yii2 project. Javascript still won't understand 'datepicker' command. Is there anything else I have to do to require this library? Maybe use 'use eternicode/...' command in a view file? Even though can't find out a proper way they form after being installed via composer.
Here's the link to github of this library: https://github.com/eternicode/bootstrap-datepicker
Upvotes: 2
Views: 4034
Reputation: 2122
You need to create an AssetBundle
so it can be registered by a View
.
<?php
namespace app\assets;
use yii\web\AssetBundle;
class DatepickerAsset extends AssetBundle
{
public $sourcePath = '@bower/bootstrap-datepicker/dist';
public $js = ['js/bootstrap-datepicker.min.js'];
public $css = ['css/bootstrap-datepicker.min.css'];
}
The above is an example as I don't know what folders will be created by composer.
Then in the view,
<?php
DatepickerAsset::register($this);
This will insert the necessary script and css tags into the output.
Upvotes: 1