public function actionCreate() { $model = new Category(); if (isset($_POST['Category'])) { $model->setAttributes($_POST['Category']); try { if ($model->save()) { if (isset($_GET['returnUrl'])) { $this->redirect($_GET['returnUrl']); } else { $this->redirect(array('view', 'id' => $model->id)); } } } catch (Exception $e) { $model->addError('', $e->getMessage()); } } elseif (isset($_GET['Category'])) { $model->attributes = $_GET['Category']; } $this->render('create', array('model' => $model)); }