public function getPriceCategory() { return $this->hasOne(FPriceCategory::className(), ['id_category' => 'id']); }
public function actionItem() { $get = Yii::$app->request->get(); $id = $get["id"]; $cat = FCategory::findOne($id); $option = FPriceCategory::findOne(["id_category" => $id]); if (!$option) { $option = new FPriceCategory(); $option->id_category = $id; $option->save(); } if (Yii::$app->request->isPost) { $post = Yii::$app->request->post(); $option->load($post); if ($option->validate()) { $option->save(); } } return $this->render('item', ['r_cat' => $cat, 'option' => $option]); }