ianikanov/yii2-wce
最新稳定版本:0.3
Composer 安装命令:
composer require ianikanov/yii2-wce
包简介
Ability to generate widgets with interface similar to controller with basic CRUD actions for specific model
关键字:
README 文档
README
Ability to generate widgets with interface similar to controller with basic CRUD actions for specific model
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist ianikanov/yii2-wce "dev-master"
or add
"ianikanov/yii2-wce": "dev-master"
to the require section of your composer.json file.
Usage
Once the extension is installed, add new template to your config file :
if (YII_ENV_DEV) { $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', 'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'], 'generators' => [ //here 'widgetCrud' => [ 'class' => '\ianikanov\wce\templates\crud\Generator', 'templates' => [ 'WCE' => '@vendor/ianikanov/yii2-wce/templates/crud/default', // template name ], ], ], ]; }
And register embedded controller:
$config = [ ... 'controllerMap' => [ 'wce-embed' => '\ianikanov\wce\Controller', ], ... ];
Then run gii, select "CRUD Controller Widget" fill the form and generate the code.
To use widget in any other form follow examples below.
To show list of items, for example, the list of Posts related to the current model:
<?= app\widgets\PostControllerWidget::widget([ 'action' => 'index', 'params' => [ 'query' => $model->getPosts(), ], ]) ?>
To show a single item details, for example the post
<?= app\widgets\PostControllerWidget::widget([ 'action' => 'view', 'params' => [ 'id' => $post_id, ], ]) ?>
To show create button with modal window:
<?= app\widgets\PostControllerWidget::widget(['action' => 'create']) ?>
To show update button with modal window:
<?= app\widgets\PostControllerWidget::widget(['action' => 'update', 'params'=>['id' => $model->id]]) ?>
To show delete button:
<?= app\widgets\PostControllerWidget::widget(['action' => 'delete', 'params'=>['id' => $model->id]]) ?>
统计信息
- 总下载量: 2.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-24