/** * Creates a new Comics model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Comics(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if (isset($model->comic_pages)) { if ($model->comic_pages) { $temp_array = json_decode($model->comic_pages); sort($temp_array); $model->comic_pages = json_encode($temp_array); $model->update(); } } return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }