/** * Creates a new Item model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Item(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionComment(ActiveRecord $parent) { $model = new Item(); $model->parent_class = get_class($parent); $model->parent_id = $parent->primaryKey; if ($model->load(\Yii::$app->request->post()) && $model->save()) { \Yii::$app->session->setFlash('success', \Yii::t('modules/comment', "Comment added")); } return $this->renderPartial('comment', compact('model')); }