Example #1
0
 public function actionUpdate($id)
 {
     $id = intval($id);
     if ($id <= 0) {
         throw new HttpException(404, 'Указанный Вами товар не найден');
     }
     $good_current = Good::findOne($id);
     if (!$good_current) {
         throw new HttpException(404, 'Указанный Вами товар не найден');
     }
     $categories = Category::find()->asArray()->all();
     $categories_output = [];
     Category::selfTree($categories_output, $categories, 0, 0);
     return $this->render('form', ['controller_title' => 'Изменение товара ' . $good_current->name, 'form' => new \app\models\GoodForm(), 'categories' => $categories_output, 'catalog_id' => $good_current->category_id, 'good_current' => $good_current, 'id' => $id]);
 }