public function actionRemove() { $model_action = new \app\modelsActiveRecords\Actions(); $id = (int) yii::$app->request->get('id'); $this->GetModel()->RemoveItem($id); $model_action->deleteAll("page_id = :id", ["id" => $id]); $this->redirect(Url::toRoute(["/page_types/catalog"])); }
/** * Создание действия для страницы */ public function __ModelCreateActionsForPage($rowParams = [], $value = "", $item = []) { $params = $this->MakeRowParams($rowParams["params"]); $model = new \app\modelsActiveRecords\DinamicModel(); $model->setTableName($params["table"]); $id = !empty(yii::$app->request->get('id')) ? yii::$app->request->get('id') : 0; if (yii::$app->request->isPost) { $model_admin = new \app\base\ModelAdmin(); $id = !empty($id) ? $id : $model_admin->GetLastInsertId($rowParams["model_id"]); $data = yii::$app->request->post($rowParams['name']); $model = new \app\modelsActiveRecords\Actions(); $model->Add($id, $data); } $tag = Html::a(Html::tag('i', "", ["class" => "fa fa-plus"]) . 'Добавить действие', 'javascript:void(0)', ["onclick" => "addAction(this, '{$rowParams['name']}')"]); $tag .= Html::beginTag('table', ["style" => "width:440px"]); $data = $model->find()->where(["page_id" => $id])->asArray()->all(); if ($data) { foreach ($data as $index => $value) { $tag .= Html::beginTag('tr'); $tag .= Html::tag('td', Html::textInput("{$rowParams['name']}[{$index}][name]", $value["name"])); $tag .= Html::tag('td', Html::textInput("{$rowParams['name']}[{$index}][value]", $value["value"])); $tag .= Html::tag('td', html::a('Удалить', 'javascript:void(0)', ['onclick' => 'removeRow(this)'])); $tag .= Html::endTag('tr'); } } $tag .= Html::endTag('table'); return $tag; }