I want to create my own widgets.
Can the directory stucture be the same as Yii1, where I put my widget in components/ folder and views for the widget in componenets/views folder?
How should I call a widget in a view? The same as the bootstrap widgets are used? In view:
<?= MyWidgetClassName::widget(); ?>
Yes, but you forgot the namespace i guess, for example:
<?php echo \frontend\widgets\RegisterForm::widget(); ?>
And what about rendering a view inside the widget:
class BottomBar extends Widget
public function run()
I put the bottomBar.php in widgets/views/. Now I use it in the view, generated by SiteController:
The view file does not exist: /home/user/public_html/views/site/bottomBar.php
Create a views directory inside your widgets directory. So it will be like widgets/views/bottomBar.php.