/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Aposta(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['ajax'])) { $model->id_confronto = $_POST['$id_confronto']; $model->placa_visitante = $_POST['$placa_visitante']; $model->placar_casa = $_POST['$placar_casa']; $model->data = $_POST['$data']; $model->id_user = $_POST['$id_user']; $model->save(); echo json_encode($model); Yii::app()->end(); } if (isset($_POST['Aposta'])) { $model->attributes = $_POST['Aposta']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }