/** * Creates a new Compraproduto model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Compraproduto(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $novoPreco = Yii::$app->request->post()['Compraproduto']['valorCompra']; $model->comparaPrecoProduto($novoPreco); return $this->redirect(['view', 'idCompra' => $model->idCompra, 'idProduto' => $model->idProduto]); } else { return $this->render('create', ['model' => $model]); } }