/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($cellar_id) { $model = new CellarWines(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $model->cellar_id = $cellar_id; if (isset($_POST['CellarWines'])) { $model->attributes = $_POST['CellarWines']; if ($model->save()) { // update wine->overall_rating average. $current_wine = new Wines(); $current_wine->refreshRating(); if ($current_wine->save()) { $this->redirect(array('view', 'id' => $model->id)); } } } $this->render('create', array('model' => $model)); }