/** * Creates a new Task model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $course_id = Yii::$app->request->get('course_id'); $model = new Task(); if ($model->load(Yii::$app->request->post())) { $model = $model->validateAttr($model); if (empty($model->errors)) { $resourceModel = new Resource(); $model = $resourceModel->uploadImg($model, 'image'); if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } } } $model->course_id = $course_id; if (!json_decode($model->answer_json)) { $model->answer_json = ''; } $chapterName = $courseName = null; if (!empty($course_id)) { $chapterName = Course::findModel($course_id)->name; $courseName = Course::findRoot($course_id)->name; } return $this->render('create', ['model' => $model, 'courseId' => $course_id, 'chapterName' => $chapterName, 'courseName' => $courseName]); }
'attribute' => 'status', 'value' => $statusList[$model->status], ], [ 'attribute' => 'resource_type', 'value' => $typeList[$model->resource_type], ], [ 'attribute' => 'course_id', 'label' => Yii::t('app', 'Chapter'), 'value' => Course::findModel($model->course_id)->name, ], [ 'attribute' => 'course_id', 'label' => Yii::t('app', 'Course'), 'value' => Course::findRoot($model->course_id)->name, ], 'play_count', 'download_count', 'create_time', 'update_time', ], ]) ?> <p> <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [ 'class' => 'btn btn-danger', 'data' => [ 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post',
return Html::a($model->name . '.' . $model->extension, ["play?id=$model->id"]); } ], 'size', // 'duration', [ 'label' => Yii::t('app', 'Chapter'), 'value' => function ($model) { return Course::findModel($model->course_id)->name; } ], [ 'label' => Yii::t('app', 'Course'), 'attribute' => 'course_id', 'value' => function ($model) { return Course::findRoot($model->course_id)->name; } ], 'play_count', 'download_count', ['class' => 'yii\grid\ActionColumn'], ], ]); ?> </div>