/**
  * Creates a new Comments model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Comments();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->idcomments]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #2
0
 public function init()
 {
     parent::init();
     $model = new Comments();
     if ($this->class_name != null) {
         $model->class_name = $this->class_name;
     }
     if ($this->item_id != null) {
         $model->item_id = $this->item_id;
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
     }
 }
 public function actionComment()
 {
     $frm = new Comments();
     if ($frm->load(Yii::$app->request->post())) {
         //TODO: this is considered as given
         $frm->idtodo = 1;
         $frm->iduser = Yii::$app->user->id;
         if ($frm->save()) {
             echo "success";
         } else {
             print_r($frm->getErrors());
         }
     }
 }
 /**
  * Creates a new Comments model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Comments();
     $model->load(Yii::$app->request->post()) && $model->save();
     return $this->redirect(['post/view', 'id' => $model->id_post]);
 }