/** * save template of checklist along with some information to db * @return json content checklist */ public function actionSavecontent() { $post = Yii::$app->request->post(); $id = $post['id']; $content = $post['content']; if ($id && $content) { $checklistCow = ChecklistsCow::findOne($id); $checklistCow->content = $content; // save whole change to db if ($checklistCow->save()) { Yii::$app->response->format = 'json'; return ['errors' => '', 'data' => '']; } } return; }
<?php use app\models\Checklist; use app\models\ChecklistsCow; ?> <table id="checklist" class="table table-striped table-vcenter"> <tbody> <?php $cowid = Yii::$app->request->get('id'); $checklistCow = ChecklistsCow::find()->where(['belong_to' => $belong_to, 'clients_or_webs_id' => $cowid])->all(); if ($checklistCow) { foreach ($checklistCow as $key => $clcow) { ?> <tr> <td> <?php echo $clcow->checklist->title; ?> <br> <small> <span class="badge"><i class="fa fa-clock-o"></i> Created: <?php echo date('j. F Y', strtotime($clcow->created_at)); ?> </span> <span class="badge"><i class="fa fa-user"></i> By: <?php echo $clcow->user->fullname; ?> </span> <?php if ($clcow->timesent) { ?>