Example #1
0
 public function actionEdit()
 {
     $this->layout = 'default';
     $id = Yii::$app->request->get('id', -1);
     $style = Style::findOne(['id' => $id]);
     if (!$style) {
         Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Стиль не найден'));
         $this->redirect(Url::toRoute(['styles/index']));
     }
     $fonts = Font::find()->all();
     $fonts = ArrayHelper::map($fonts, 'id', 'name');
     $style->data = json_decode($style->data, true);
     return $this->render('edit', ['style' => $style, 'fonts' => $fonts]);
 }