In Yii 1 it was possible to publish an asset with:
Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.MyWidget.assets'));
How can I publish an asset within a widget in Yii2?
In your view of your widget:
app\assets\AppAsset::register($this); // $this == the View object
Check the docs.
Simplest way of doing this:
app\assets\AppAsset::register($this->getView());
It is the same way you would publish it in a view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With