public function actionAgregarproyecto() { $model = new Proyectos('create'); if (isset($_POST['Proyectos'])) { $model->attributes = $_POST['Proyectos']; $usuario = Usuarios::model()->findByPk(Yii::app()->user->getId()); $model->ente_organo_id = $usuario->ente_organo_id; if ($model->save()) { Yii::app()->user->setFlash('success', "Proyecto creado con éxito!"); // $this->redirect(array('view','id'=>$model->producto_id)); $model = new Proyectos('create'); $this->render('agregarproyecto', array('model' => $model)); // form inputs are valid, do something here return; } } $this->render('agregarproyecto', array('model' => $model)); }