Showing posts with label yii2 override widget. Show all posts
Showing posts with label yii2 override widget. Show all posts

Monday, March 26, 2018

How to create custom widget in Yii2

Create custom widget in Yii2


In this example We am creating a dropdown widget. This is only provide a basic structure of how to create your own custom widget.


Following files you need to create for widget.

1. _template.php
        print_r($model);
        die;

2.GridviewDropdown.php
namespace common\widgets\dropdownWidget;
use yii\base\Widget;
public function init(){
    parent::init(); } public function run(){     return $this->render('_template', ['items' => $this->data]);
   }
}
3.viewFile.php
echo \common\widgets\dropdownWidget\GridviewDropdown::widget([
            'model' => $model
    ])


Recent Update

yii2 session handling

use yii\web\Session; $session = Yii::$app->session; // start session $session->open(); // close session $session->close(); ...

Most Search