/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new File(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['File'])) { $model->attributes = $_POST['File']; // save file attributes from location $model->setSizeValue(); if ($model->save()) { if (isset($_POST['File']['sample_name'])) { $fs = new FileSample(); $fs->sample_id = $_POST['File']['sample_name']; $fs->file_id = $model->id; $fs->save(false); } if ($model->location) { $extension = $format = null; $this->getFileExtension($model->name, $extension, $format); $this->setAutoFileAttributes($model); } $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }