/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new TestContext(); $model->id_user = Yii::app()->user->getId(); $modelsApps = App::model()->findAll(); $appsArray = CHtml::listData($modelsApps, 'id', 'name'); $modelsPlatforms = Platforms::model()->findAll(); $platformsArray = CHtml::listData($modelsPlatforms, 'id', 'name'); $user_name = Yii::app()->user->getName(); $users = Users::model()->findAllByAttributes(array('user_name' => $user_name)); $name = ""; foreach ($users as $user) { $name = $user->name; } $devicesArray = array(); // Uncomment the following line if AJAX validation is needed if (isset($_POST['buttonCancel'])) { $this->redirect(array('admin')); } if (isset($_POST['TestContext'])) { //$_SESSION['flag-test-context-form']=null; $model->attributes = $_POST['TestContext']; if ($model->save()) { Yii::app()->user->setState('idTestContext', $model->id); Yii::app()->user->setState('idDevice', $model->id_device); $this->redirect("/mtcontrool/index.php/elementInst/create1"); } } $this->render('create', array('model' => $model, 'appsArray' => $appsArray, 'platformsArray' => $platformsArray, 'devicesArray' => $devicesArray, 'name' => $name)); }