ivankff/yii2-external-crud
Composer 安装命令:
composer require ivankff/yii2-external-crud
包简介
yii2 Create, Update, Delete, View external actions for backend
关键字:
README 文档
README
Controller
public function actions() { return [ ... 'create' => [ 'class' => 'ivankff\yii2ExternalCrud\actions\CreateAction', 'view' => 'update', 'additionalQueryParams' => ['F.categoryId'], 'model' => function ($action) { $categoryId = Yii::$app->request->get('categoryId'); $config = []; if ($categoryId) $config = ['categories' => $categoryId]; $model = new ProductForm(new Product(), $config); $model->status = 1; if (Yii::$app->user->can('backend.product.webmaster')) $model->setScenario(ProductForm::SCENARIO_WEBMASTER); return $model; }, 'on ' . WriteAction::EVENT_BEFORE_VIEW => function ($event) { /** @var ActionWriteViewEvent $event */ $event->viewParams['categories'] = $this->getCategories(); } ], 'update' => [ 'class' => 'ivankff\yii2ExternalCrud\actions\UpdateAction', 'view' => 'update', 'additionalQueryParams' => ['F.categoryId'], 'model' => function ($id, $action) { $model = new ProductForm($this->findModel($id)); if (Yii::$app->user->can('backend.product.webmaster')) $model->setScenario(ProductForm::SCENARIO_WEBMASTER); return $model; }, 'on ' . WriteAction::EVENT_BEFORE_VIEW => function ($event) { /** @var ActionWriteViewEvent $event */ $event->viewParams['categories'] = $this->getCategories(); } ], 'delete' => [ 'class' => 'ivankff\yii2ExternalCrud\actions\DeleteAction', 'model' => function ($id, $action) { return $this->findModel($id); }, ], ... ]; }
统计信息
- 总下载量: 91
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2018-12-19